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
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.
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.ui.action.BaseAction
BaseAction.EnabledRule
Nested classes/interfaces inherited from interface io.jmix.ui.action.Action
Action.ActionPerformedEvent, Action.AdjustWhenScreenReadOnly, Action.ExecutableAction, Action.HasPrimaryState, Action.HasSecurityConstraint, Action.HasTarget, Action.MainTabSheetAction, Action.ScreenOpeningAction, Action.SecuredAction, Action.Status
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
static final String
protected Messages
protected ScreenBuilders
protected ActionScreenInitializer
Fields inherited from class io.jmix.ui.action.list.SecuredListAction
accessManager, applicationContext, constraintEntityOp, metadata
Fields inherited from class io.jmix.ui.action.ListAction
target
Fields inherited from class io.jmix.ui.action.AbstractAction
caption, description, enabled, eventHub, icon, id, owners, primary, shortcut, visible
Fields inherited from interface io.jmix.ui.action.Action
PROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
actionPerform
(Component component) Invoked by owning component to execute the action.void
execute()
Executes the action.Returns the screen open mode if it was set byAction.ScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returnsnull
.Returns the editor screen class if it was set bysetScreenClass(Class)
or in the screen XML.Returns the editor screen id if it was set bysetScreenId(String)
or in the screen XML.boolean
protected boolean
Callback method which is invoked by the action to determine its enabled state.void
Refresh internal state of the action to initialize enabled, visible, caption, icon, etc.void
setAfterCloseHandler
(Consumer<Screen.AfterCloseEvent> afterCloseHandler) Sets the handler to be invoked when the editor screen closes.void
setAfterCommitHandler
(Consumer<E> afterCommitHandler) Sets the handler to be invoked when the editor screen commits the entity.void
setCaption
(String caption) protected void
protected void
setMessages
(Messages messages) void
setOpenMode
(OpenMode openMode) Sets the screen open mode.void
setScreenBuilders
(ScreenBuilders screenBuilders) void
setScreenClass
(Class<? extends Screen> screenClass) Sets the editor screen id.void
setScreenConfigurer
(Consumer<Screen> screenConfigurer) Sets the editor screen configurer.void
setScreenId
(String screenId) Sets the editor screen id.void
setScreenOptionsSupplier
(Supplier<ScreenOptions> screenOptionsSupplier) Sets the editor screen options supplier.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.protected void
setUiComponentProperties
(UiComponentProperties componentProperties) Methods inherited from class io.jmix.ui.action.list.SecuredListAction
getConstraintEntityOp, isApplicable, setAccessManager, setApplicationContext, setConstraintEntityOp, setMetadata
Methods inherited from class io.jmix.ui.action.ListAction
getTarget, setTarget, withCaption, withDescription, withHandler, withIcon, withPrimary, withShortcut
Methods inherited from class io.jmix.ui.action.BaseAction
addActionPerformedListener, addEnabledRule, isEnabledByRule, isEnabledByUiPermissions, isVisibleByUiPermissions, removeEnabledRule, setEnabled, setEnabledByUiPermissions, setEnabledInternal, setVisible, setVisibleByUiPermissions, setVisibleInternal
Methods inherited from class io.jmix.ui.action.AbstractAction
addOwner, addPropertyChangeListener, firePropertyChange, getCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setDescription, setIcon, setPrimary, setShortcut, setShortcutCombination
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.ui.action.Action
addOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, removeOwner, removePropertyChangeListener, setDescription, setEnabled, setIcon, setShortcut, setShortcutCombination, setVisible
-
Field Details
-
ID
- See Also:
-
screenBuilders
-
screenInitializer
-
afterCommitHandler
-
transformation
-
messages
-
-
Constructor Details
-
EditAction
public EditAction() -
EditAction
-
-
Method Details
-
getOpenMode
Description copied from interface:Action.ScreenOpeningAction
Returns the screen open mode if it was set byAction.ScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returnsnull
.- Specified by:
getOpenMode
in interfaceAction.ScreenOpeningAction
-
setOpenMode
Description copied from interface:Action.ScreenOpeningAction
Sets the screen open mode.- Specified by:
setOpenMode
in interfaceAction.ScreenOpeningAction
- Parameters:
openMode
- the open mode to set
-
getScreenId
Returns the editor screen id if it was set bysetScreenId(String)
or in the screen XML. Otherwise returns null.- Specified by:
getScreenId
in interfaceAction.ScreenOpeningAction
-
setScreenId
Sets the editor screen id.- Specified by:
setScreenId
in interfaceAction.ScreenOpeningAction
- Parameters:
screenId
- the screen id to set
-
getScreenClass
Returns the editor screen class if it was set bysetScreenClass(Class)
or in the screen XML. Otherwise returns null.- Specified by:
getScreenClass
in interfaceAction.ScreenOpeningAction
-
setScreenClass
Sets the editor screen id.- Specified by:
setScreenClass
in interfaceAction.ScreenOpeningAction
- Parameters:
screenClass
- the screen class to set
-
setScreenOptionsSupplier
Sets the editor screen options supplier. The supplier providesScreenOptions
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 interfaceAction.ScreenOpeningAction
-
setScreenConfigurer
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 interfaceAction.ScreenOpeningAction
-
setAfterCloseHandler
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 interfaceAction.ScreenOpeningAction
-
setAfterCommitHandler
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
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
-
setMessages
-
setUiComponentProperties
-
setScreenBuilders
-
setCaption
- Specified by:
setCaption
in interfaceAction
- Overrides:
setCaption
in classAbstractAction
-
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 classSecuredListAction
- 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 interfaceAction
- Overrides:
refreshState
in classBaseAction
-
isDisabledWhenScreenReadOnly
public boolean isDisabledWhenScreenReadOnly()- Specified by:
isDisabledWhenScreenReadOnly
in interfaceAction.AdjustWhenScreenReadOnly
- Returns:
- whether this action must be disabled when a screen in the read-only mode
-
actionPerform
Description copied from interface:Action
Invoked by owning component to execute the action.- Specified by:
actionPerform
in interfaceAction
- Overrides:
actionPerform
in classBaseAction
- Parameters:
component
- invoking component
-
execute
public void execute()Executes the action.- Specified by:
execute
in interfaceAction.ExecutableAction
-