Which commmand to use to edit multi valued attribute #228
Replies: 2 comments 7 replies
-
Hi @quratulain-ali , a SetCommand with a path that includes the index of the property you want to edit should do the trick. Best, |
Beta Was this translation helpful? Give feedback.
-
Hi, In EMF, the SetCommand is indeed what you need. If you want to replace the entire collection with a new list, you don't have to worry about indices: you can simply specify the new list as the value of the Set command: List<?> newListValue = getNewValue();
Command command = SetCommand.create(editingDomain, eObject, eFeature, newListValue); In that case, we simply expect the eFeature to be multivalued (upperbound > 1) Based on your latest reply, I assume you're using the const newListValue = getNewValue();
const command = new SetCommand(owner, feature, [newListValue]); The trick is that the SetCommand isn't really clear about what the type of "newListValue" should be. For setting a new list value, the server expects a single value (We're not adding multiple elements; we're replacing the entire list as an atomic operation, so we need only one value. But this single value can be an array of objects). I think there might be an issue with the way the SetCommand constructor is typed; so it might not actually allow the [newListValue] argument (it expects an array of EObjects like A workaround for this issue would be to create a CompoundCommand that contains two sub-commands:
(Note: you should still try the SetCommand with the array value first; but if that doesn't work, fallback to the suggested workaround). HTH, |
Beta Was this translation helpful? Give feedback.
-
Which model server command to use to edit multi-valued properties? When I use the AddCommand it adds the element to multivalued property? Is there a ReplaceCommand available?
Beta Was this translation helpful? Give feedback.
All reactions