Actions
Action is an interface that abstracts an action (in other words, some function) from a visual component. It is particularly useful when the same action can be invoked from different visual components (for example, both from a button and a table context menu). Action also defines some common properties, such as caption, keyboard shortcuts, flags of accessibility and visibility, etc.
Creating Actions
The framework supplies a collection of Standard Actions for views, list components, and picker components. Besides, you can create custom actions using one of the three approaches:
-
Declarative Actions: declare an action in view XML and implement its handler.
-
Custom Action Types: create an action class and reuse it by type across application views.
-
Programmatic Actions: create an action "in-place" in the view controller.
Components that Can Host Actions
The following components can host actions:
-
Single-action components implement the
HasActioninterface. For example, button. To set an action useHasAction.setAction(). -
Multi-action components implement the
HasActionsinterface. For example: dataGrid, entityComboBox, entityPicker. To set an action useHasActions.addAction().The implementation checks for an existing action with the same identifier; if found, it replaces the old action. This allows a standard action declared in a view descriptor to be overridden programmatically in a controller with different properties. -
Views themselves can contain actions. Define them in the top‑level
<actions>XML element or add programmatically using thegetViewActions.addAction()method of the view class.