Standard Actions

The framework provides standard actions to solve common tasks, such as an invocation of a detail view for an entity selected in a dataGrid. A standard action should be used in the view XML descriptor by specifying its type in the type attribute of the action element.

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 action XML attributes to override default properties: text, icon, shortcutCombination, etc. For example:

<action id="create" type="list_create"
        actionVariant="SUCCESS" icon="PLUS_CIRCLE"/>

There are several categories of standard actions:

Additional Properties

Standard actions usually 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 of the action class:

<action id="edit" type="list_edit">
    <properties>
        <property name="viewId" value="CustomDepartmentDetailView"/>
    </properties>
</action>

The same can be done in Java controller:

@ViewComponent("myDepartmentsTable.edit")
private EditAction<Department> myDepartmentsTableEdit;

@Subscribe
public void onInit(final InitEvent event) {
    myDepartmentsTableEdit.setViewId("CustomDepartmentDetailView");
}

Installing Handlers

If an action’s setter accepts a functional interface (handler), you can install the handler using an annotated method in the view controller. For example, CreateAction has the setAfterSaveHandler(Consumer) method which is used to set a handler to be invoked after the created entity is saved. Then you can provide the handler in the view controller as follows:

@Install(to = "departmentsTable.create", subject = "afterSaveHandler")
private void departmentsTableCreateAfterSaveHandler(final Department department) {
    notifications.create("Created " + department).show();
}

To generate a handler stub in Jmix Studio, use the Handlers tab of the Jmix UI inspector panel or the Generate Handler action available in the top panel of the view class and through the CodeGenerate menu (Alt+Insert / Cmd+N).