3.5.5. 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, from button and table context menu). Action also defines some common properties, such as caption, keyboard shortcut, flags of accessibility and visibility, etc.

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

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

  • Visual components with a single action implement the Component.ActionOwner interface. These are Button and LinkButton.

    An action is linked to the component by invoking the ActionOwner.setAction() method of the component. At this point, the component replaces its properties with corresponding properties of the action (see components overview for details).

  • Visual components containing several actions implement the Component.ActionsHolder interface. These are Window, Fragment, DataGrid, Table and its inheritors, Tree, PopupButton, PickerField, LookupPickerField.

    The ActionsHolder.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 screen descriptor and then create a new one in the controller with different properties and add it to the component.