Standard Actions

Standard actions are provided by the framework to solve common tasks, such as invocation of an edit screen for an entity selected in a table. A standard action can be declared in screen XML descriptor by specifying its type in the type attribute, for example:

<!-- in a table -->
<action type="create"/>

<!-- in a PickerField -->
<action id="lookup" type="picker_lookup"/>

The standard action configures itself depending on its type and owning component. It may or may not require additional parameters.

There are two categories of standard actions:

You can create similar actions or override existing standard types in your project.

For example, imagine that you need an action that would show the instance name of the currently selected entity in a table, and you would like to use this action in multiple screens by specifying its type only. Below are the steps to create such action.

  1. Create an action class and add the @ActionType annotation with the desired type name:

    package com.company.sample.web.actions;
    import com.haulmont.cuba.core.entity.Entity;
    import com.haulmont.cuba.core.global.MetadataTools;
    import com.haulmont.cuba.gui.ComponentsHelper;
    import com.haulmont.cuba.gui.Notifications;
    import com.haulmont.cuba.gui.components.ActionType;
    import com.haulmont.cuba.gui.components.Component;
    import com.haulmont.cuba.gui.components.actions.ItemTrackingAction;
    import javax.inject.Inject;
    public class ShowSelectedAction extends ItemTrackingAction {
        private MetadataTools metadataTools;
        public ShowSelectedAction(String id) {
            setCaption("Show Selected");
        public void actionPerform(Component component) {
            Entity selected = getTarget().getSingleSelected();
            if (selected != null) {
                Notifications notifications = ComponentsHelper.getScreenContext(target).getNotifications();
  2. In the web-spring.xml file, add <gui:actions> element with the base-packages attribute pointing to a package where to find your annotated actions:

    <beans ... xmlns:gui="http://schemas.haulmont.com/cuba/spring/cuba-gui.xsd">
        <!-- ... -->
        <gui:actions base-packages="com.company.sample.web.actions"/>
  3. Now you can use the action in screen descriptors by specifying its type:

    <groupTable id="customersTable">
            <action id="show" type="showSelected"/>
            <!-- ... -->
            <button action="customersTable.show"/>