Standard Actions

The framework provides standard actions to solve common tasks, such as an invocation of an edit screen for an entity selected in a table. A standard action should be declared in the screen XML descriptor by specifying its type in the type attribute.

Each standard action is implemented by a class annotated with @ActionType("<some_type>"). The class defines the action’s default properties and behavior.

You can specify any basic action XML attributes to override common action properties: caption, icon, shortcut, etc. For example:

<action id="create" type="create"
        caption="Create customer" icon="USER_PLUS"/>

There are two categories of standard actions:

List Actions

List actions work with collections of entities that are displayed in tables or trees. These are AddAction, BulkEditAction, CreateAction, EditAction, ExcludeAction, RefreshAction, RelatedAction, RemoveAction, ViewAction.

When a list action is added to a table, tree, or data grid, it can be invoked from the component’s context menu item and by its predefined keyboard shortcut. Usually, the action is also invoked by a button added to the buttons panel.

<groupTable id="customersGroupTable"
        <action id="create" type="create"/>
        <action id="edit" type="edit"/>
        <action id="remove" type="remove"/>
        <column id="firstName"/>
        <column id="lastName"/>
    <buttonsPanel alwaysVisible="true">
        <button action="customersGroupTable.create"/>
        <button action="customersGroupTable.edit"/>
        <button action="customersGroupTable.remove"/>

Picker Actions

When a picker action is added to the component, it is automatically represented by a button inside the field.

<entityPicker dataContainer="orderDc"
        <action id="lookup" type="entity_lookup"/>
        <action id="open" type="entity_open"/>
        <action id="clear" type="entity_clear"/>

Additional Properties

Standard actions have additional properties that can be set in XML or using setters in Java. In XML, additional properties are configured using the nested <properties> element, where each <property> element corresponds to a setter existing in this action class:

<action id="create" type="create">
        <property name="openMode" value="DIALOG"/>
        <property name="screenClass" value="ui.ex1.screen.entity.customer.CustomerEdit"/>

The same can be done in Java controller:

private CreateAction<Customer> createAction;

public void onInit(InitEvent event) {

Installing Handlers

If a setter accepts a functional interface, you can install a handler method in the screen controller. For example, CreateAction has setAfterCommitHandler(Consumer) method which is used to set a handler to be invoked after the created entity is committed. Then you can provide the handler as follows:

@Install(to = "customersGroupTable.create", subject = "afterCommitHandler")
private void customersGroupTableCreateAfterCommitHandler(Customer customer) {
            .withCaption("Created  " + customer)

You can generate handlers implementation stubs using Studio.

There is a common enabledRule handler available to all actions, which allows you to set the action "enabled" state depending on the situation. In the example below, it disables RemoveAction for some entities:

private GroupTable<Customer> customersGroupTable;

@Install(to = "customersGroupTable.remove", subject = "enabledRule")
private boolean customersGroupTableRemoveEnabledRule() {
    Set<Customer> customers = customersGroupTable.getSelected();
    return canBeRemoved(customers);