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.

You can create actions declaratively in view XML or by creating classes inherited from BaseAction. Also, there is a set of provided by the framework standard actions for views, list and picker components.

Visual components associated with an action can be of two types:

  • Visual components with a single action implement the HasAction interface. For example, button.

    An action is linked to the component by invoking the HasAction.setAction() method.

  • Visual components containing multiple actions implement the HasActions interface. For example dataGrid, entityComboBox, entityPicker.

    The HasActions.addAction() method is used to add actions to the component. Implementation of this method in the component checks whether it already contains an action with the same identifier. If yes, then the existing action will be replaced with the new one. Therefore, it is possible, for example, to declare a standard action in a view descriptor and then create a new one programmatically in the controller with different properties and add it to the component.

  • A view itself can also contain actions. You can define them in the top-level <actions> element of XML descriptor, or add programmatically using the getViewActions.addAction() method of the view class.