Class EditAction<E>

Type Parameters:
E - type of entity
All Implemented Interfaces:
Action, Action.AdjustWhenScreenReadOnly, Action.ExecutableAction, Action.HasPrimaryState, Action.HasSecurityConstraint, Action.HasTarget, Action.ScreenOpeningAction, Action.SecuredAction

@StudioAction(target="io.jmix.ui.component.ListComponent", description="Edits an entity instance using its editor screen", availableInScreenWizard=true) @ActionType("edit") public class EditAction<E> extends SecuredListAction implements Action.AdjustWhenScreenReadOnly, Action.ScreenOpeningAction, Action.ExecutableAction
Standard action for editing an entity instance using its editor screen.

Should be defined for a list component (Table, DataGrid, etc.) in a screen XML descriptor.

The action instance can be parameterized using the nested properties XML element or programmatically in the screen controller.

  • Field Details

  • Constructor Details

    • EditAction

      public EditAction()
    • EditAction

      public EditAction(String id)
  • Method Details

    • getOpenMode

      @Nullable public OpenMode getOpenMode()
      Description copied from interface: Action.ScreenOpeningAction
      Returns the screen open mode if it was set by Action.ScreenOpeningAction.setOpenMode(OpenMode) or in the screen XML, otherwise returns null.
      Specified by:
      getOpenMode in interface Action.ScreenOpeningAction
    • setOpenMode

      @StudioPropertiesItem public void setOpenMode(@Nullable OpenMode openMode)
      Description copied from interface: Action.ScreenOpeningAction
      Sets the screen open mode.
      Specified by:
      setOpenMode in interface Action.ScreenOpeningAction
      Parameters:
      openMode - the open mode to set
    • getScreenId

      @Nullable public String getScreenId()
      Returns the editor screen id if it was set by setScreenId(String) or in the screen XML. Otherwise returns null.
      Specified by:
      getScreenId in interface Action.ScreenOpeningAction
    • setScreenId

      @StudioPropertiesItem public void setScreenId(@Nullable String screenId)
      Sets the editor screen id.
      Specified by:
      setScreenId in interface Action.ScreenOpeningAction
      Parameters:
      screenId - the screen id to set
    • getScreenClass

      @Nullable public Class<? extends Screen> getScreenClass()
      Returns the editor screen class if it was set by setScreenClass(Class) or in the screen XML. Otherwise returns null.
      Specified by:
      getScreenClass in interface Action.ScreenOpeningAction
    • setScreenClass

      @StudioPropertiesItem public void setScreenClass(@Nullable Class<? extends Screen> screenClass)
      Sets the editor screen id.
      Specified by:
      setScreenClass in interface Action.ScreenOpeningAction
      Parameters:
      screenClass - the screen class to set
    • setScreenOptionsSupplier

      public void setScreenOptionsSupplier(Supplier<ScreenOptions> screenOptionsSupplier)
      Sets the editor screen options supplier. The supplier provides ScreenOptions to the opened screen.

      The preferred way to set the supplier is using a controller method annotated with Install, e.g.:

       @Install(to = "petsTable.edit", subject = "screenOptionsSupplier")
       protected ScreenOptions petsTableEditScreenOptionsSupplier() {
           return new MapScreenOptions(ParamsMap.of("someParameter", 10));
       }
       
      Specified by:
      setScreenOptionsSupplier in interface Action.ScreenOpeningAction
    • setScreenConfigurer

      public void setScreenConfigurer(Consumer<Screen> screenConfigurer)
      Sets the editor screen configurer. Use the configurer if you need to provide parameters to the opened screen through setters.

      The preferred way to set the configurer is using a controller method annotated with Install, e.g.:

       @Install(to = "petsTable.edit", subject = "screenConfigurer")
       protected void petsTableEditScreenConfigurer(Screen editorScreen) {
           ((PetEdit) editorScreen).setSomeParameter(someValue);
       }
       
      Specified by:
      setScreenConfigurer in interface Action.ScreenOpeningAction
    • setAfterCloseHandler

      public void setAfterCloseHandler(Consumer<Screen.AfterCloseEvent> afterCloseHandler)
      Sets the handler to be invoked when the editor screen closes.

      The preferred way to set the handler is using a controller method annotated with Install, e.g.:

       @Install(to = "petsTable.edit", subject = "afterCloseHandler")
       protected void petsTableEditAfterCloseHandler(AfterCloseEvent event) {
           if (event.closedWith(StandardOutcome.COMMIT)) {
               System.out.println("Committed");
           }
       }
       
      Specified by:
      setAfterCloseHandler in interface Action.ScreenOpeningAction
    • setAfterCommitHandler

      public void setAfterCommitHandler(Consumer<E> afterCommitHandler)
      Sets the handler to be invoked when the editor screen commits the entity.

      The preferred way to set the handler is using a controller method annotated with Install, e.g.:

       @Install(to = "petsTable.edit", subject = "afterCommitHandler")
       protected void petsTableEditAfterCommitHandler(Pet entity) {
           System.out.println("Committed " + entity);
       }
       
    • setTransformation

      public void setTransformation(Function<E,E> transformation)
      Sets the function to transform the committed in the editor screen entity before setting it to the target data container.

      The preferred way to set the function is using a controller method annotated with Install, e.g.:

       @Install(to = "petsTable.edit", subject = "transformation")
       protected Pet petsTableEditTransformation(Pet entity) {
           return doTransform(entity);
       }
       
    • setIcons

      @Autowired protected void setIcons(Icons icons)
    • setMessages

      @Autowired protected void setMessages(Messages messages)
    • setUiComponentProperties

      @Autowired protected void setUiComponentProperties(UiComponentProperties componentProperties)
    • setScreenBuilders

      @Autowired public void setScreenBuilders(ScreenBuilders screenBuilders)
    • setCaption

      public void setCaption(@Nullable String caption)
      Specified by:
      setCaption in interface Action
      Overrides:
      setCaption in class AbstractAction
    • isPermitted

      protected boolean isPermitted()
      Description copied from class: BaseAction
      Callback method which is invoked by the action to determine its enabled state.
      Overrides:
      isPermitted in class SecuredListAction
      Returns:
      true if the action is enabled for the current user
    • refreshState

      public void refreshState()
      Description copied from interface: Action
      Refresh internal state of the action to initialize enabled, visible, caption, icon, etc. properties depending on programmatically set values and user permissions set at runtime.

      For example, this method is called by visual components holding actions when they are bound to data. At this moment the action can find out what entity it is connected to and change its state according to the user permissions.

      Specified by:
      refreshState in interface Action
      Overrides:
      refreshState in class BaseAction
    • isDisabledWhenScreenReadOnly

      public boolean isDisabledWhenScreenReadOnly()
      Specified by:
      isDisabledWhenScreenReadOnly in interface Action.AdjustWhenScreenReadOnly
      Returns:
      whether this action must be disabled when a screen in the read-only mode
    • actionPerform

      public void actionPerform(Component component)
      Description copied from interface: Action
      Invoked by owning component to execute the action.
      Specified by:
      actionPerform in interface Action
      Overrides:
      actionPerform in class BaseAction
      Parameters:
      component - invoking component
    • execute

      public void execute()
      Executes the action.
      Specified by:
      execute in interface Action.ExecutableAction