major
nice-to-have
defect
major
A CommandHandler operates within the context of a component and refers to a business object:
#!java CommandHandler.handleCommand(DisplayContext, LayoutComponent, Object model, Map<String, Object>)
The model object is extracted from the component. To do this, the CommandHandler implementation can currently implement a hook:
#!java CommandHandler.getTargetModel(LayoutComponent)
However, the one-to-one mapping between the command implementation and the specification of the target object for the command limits the command’s usability. For example, the same command cannot be used for the object currently displayed in a form or the selected row in a table.
Improvement
The target object can be configured relative to the command’s context component. The same syntax is used for this as for defining a component’s model (model="selection(other-component)"). The syntax is slightly extended to allow reference to the component itself: target="selection(self())".
Application
Configuring the target object for a command relative to the component on which the command is configured:
#!xml <button id="delete" class="MyDeleteHandler" ... target="selection(self())" />
Test
- Refactoring: Previous overrides of ` getTargetModel() ` have been converted to use the configuration option. No additional test.