E
- type of entity@StudioAction(target="io.jmix.ui.component.ListComponent", description="Creates an entity instance using its editor screen", availableInScreenWizard=true) @ActionType(value="create") public class CreateAction<E> extends ListAction implements Action.AdjustWhenScreenReadOnly, Action.ScreenOpeningAction, Action.ExecutableAction
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.
BaseAction.EnabledRule
Action.ActionPerformedEvent, Action.AdjustWhenScreenReadOnly, Action.ExecutableAction, Action.HasPrimaryState, Action.HasSecurityConstraint, Action.HasTarget, Action.MainTabSheetAction, Action.ScreenOpeningAction, Action.SecuredAction, Action.Status
Modifier and Type | Field and Description |
---|---|
protected io.jmix.core.AccessManager |
accessManager |
protected java.util.function.Consumer<E> |
afterCommitHandler |
static java.lang.String |
ID |
protected java.util.function.Consumer<E> |
initializer |
protected java.util.function.Supplier<E> |
newEntitySupplier |
protected ScreenBuilders |
screenBuilders |
protected ActionScreenInitializer |
screenInitializer |
protected java.util.function.Function<E,E> |
transformation |
target
caption, description, enabled, eventHub, icon, id, owners, primary, shortcut, visible
PROP_CAPTION, PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_VISIBLE
Constructor and Description |
---|
CreateAction() |
CreateAction(java.lang.String id) |
Modifier and Type | Method and Description |
---|---|
void |
actionPerform(Component component)
Invoked by owning component to execute the action.
|
void |
execute()
Executes the action.
|
OpenMode |
getOpenMode()
Returns the screen open mode if it was set by
Action.ScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returns null . |
java.lang.Class<? extends Screen> |
getScreenClass()
Returns the editor screen class if it was set by
setScreenClass(Class) or in the screen XML. |
java.lang.String |
getScreenId()
Returns the editor screen id if it was set by
setScreenId(String) or in the screen XML. |
protected boolean |
isPermitted()
Callback method which is invoked by the action to determine its enabled state.
|
void |
setAccessManager(io.jmix.core.AccessManager accessManager) |
void |
setAfterCloseHandler(java.util.function.Consumer<Screen.AfterCloseEvent> afterCloseHandler)
Sets the handler to be invoked when the editor screen closes.
|
void |
setAfterCommitHandler(java.util.function.Consumer<E> afterCommitHandler)
Sets the handler to be invoked when the editor screen commits the new entity.
|
protected void |
setIcons(Icons icons) |
void |
setInitializer(java.util.function.Consumer<E> initializer)
Sets the new entity initializer.
|
protected void |
setMessages(io.jmix.core.Messages messages) |
void |
setNewEntitySupplier(java.util.function.Supplier<E> newEntitySupplier)
Sets the new entity supplier.
|
void |
setOpenMode(OpenMode openMode)
Sets the screen open mode.
|
void |
setScreenBuilders(ScreenBuilders screenBuilders) |
void |
setScreenClass(java.lang.Class<? extends Screen> screenClass)
Sets the editor screen class.
|
void |
setScreenConfigurer(java.util.function.Consumer<Screen> screenConfigurer)
Sets the editor screen configurer.
|
void |
setScreenId(java.lang.String screenId)
Sets the editor screen id.
|
void |
setScreenOptionsSupplier(java.util.function.Supplier<ScreenOptions> screenOptionsSupplier)
Sets the editor screen options supplier.
|
void |
setTransformation(java.util.function.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) |
getTarget, setTarget, withCaption, withDescription, withHandler, withIcon, withPrimary, withShortcut
addActionPerformedListener, addEnabledRule, isApplicable, isEnabledByRule, isEnabledByUiPermissions, isVisibleByUiPermissions, refreshState, removeEnabledRule, setEnabled, setEnabledByUiPermissions, setEnabledInternal, setVisible, setVisibleByUiPermissions, setVisibleInternal
addOwner, addPropertyChangeListener, firePropertyChange, getCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setPrimary, setShortcut, setShortcutCombination
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isDisabledWhenScreenReadOnly
addOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, refreshState, removeOwner, removePropertyChangeListener, setCaption, setDescription, setEnabled, setIcon, setShortcut, setShortcutCombination, setVisible
public static final java.lang.String ID
protected ScreenBuilders screenBuilders
protected io.jmix.core.AccessManager accessManager
protected ActionScreenInitializer screenInitializer
protected java.util.function.Supplier<E> newEntitySupplier
protected java.util.function.Consumer<E> initializer
protected java.util.function.Consumer<E> afterCommitHandler
public CreateAction()
public CreateAction(java.lang.String id)
@Nullable public OpenMode getOpenMode()
Action.ScreenOpeningAction
Action.ScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returns null
.getOpenMode
in interface Action.ScreenOpeningAction
@StudioPropertiesItem public void setOpenMode(@Nullable OpenMode openMode)
Action.ScreenOpeningAction
setOpenMode
in interface Action.ScreenOpeningAction
openMode
- the open mode to set@Nullable public java.lang.String getScreenId()
setScreenId(String)
or in the screen XML.
Otherwise returns null.getScreenId
in interface Action.ScreenOpeningAction
@StudioPropertiesItem public void setScreenId(@Nullable java.lang.String screenId)
setScreenId
in interface Action.ScreenOpeningAction
screenId
- the screen id to set@Nullable public java.lang.Class<? extends Screen> getScreenClass()
setScreenClass(Class)
or in the screen XML.
Otherwise returns null.getScreenClass
in interface Action.ScreenOpeningAction
@StudioPropertiesItem public void setScreenClass(@Nullable java.lang.Class<? extends Screen> screenClass)
setScreenClass
in interface Action.ScreenOpeningAction
screenClass
- the screen class to setpublic void setScreenOptionsSupplier(java.util.function.Supplier<ScreenOptions> screenOptionsSupplier)
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.create", subject = "screenOptionsSupplier") protected ScreenOptions petsTableCreateScreenOptionsSupplier() { return new MapScreenOptions(ParamsMap.of("someParameter", 10)); }
setScreenOptionsSupplier
in interface Action.ScreenOpeningAction
public void setScreenConfigurer(java.util.function.Consumer<Screen> screenConfigurer)
The preferred way to set the configurer is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "screenConfigurer") protected void petsTableCreateScreenConfigurer(Screen editorScreen) { ((PetEdit) editorScreen).setSomeParameter(someValue); }
setScreenConfigurer
in interface Action.ScreenOpeningAction
public void setAfterCloseHandler(java.util.function.Consumer<Screen.AfterCloseEvent> afterCloseHandler)
The preferred way to set the handler is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "afterCloseHandler") protected void petsTableCreateAfterCloseHandler(AfterCloseEvent event) { if (event.closedWith(StandardOutcome.COMMIT)) { System.out.println("Committed"); } }
setAfterCloseHandler
in interface Action.ScreenOpeningAction
public void setNewEntitySupplier(java.util.function.Supplier<E> newEntitySupplier)
The preferred way to set the supplier is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "newEntitySupplier") protected Pet petsTableCreateNewEntitySupplier() { Pet pet = metadata.create(Pet.class); pet.setName("a cat"); return pet; }
public void setInitializer(java.util.function.Consumer<E> initializer)
The preferred way to set the initializer is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "initializer") protected void petsTableCreateInitializer(Pet entity) { entity.setName("a cat"); }
public void setAfterCommitHandler(java.util.function.Consumer<E> afterCommitHandler)
The preferred way to set the handler is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "afterCommitHandler") protected void petsTableCreateAfterCommitHandler(Pet entity) { System.out.println("Created " + entity); }
public void setTransformation(java.util.function.Function<E,E> transformation)
The preferred way to set the function is using a controller method annotated with Install
, e.g.:
@Install(to = "petsTable.create", subject = "transformation") protected Pet petsTableCreateTransformation(Pet entity) { return doTransform(entity); }
@Autowired protected void setMessages(io.jmix.core.Messages messages)
@Autowired protected void setIcons(Icons icons)
@Autowired protected void setUiComponentProperties(UiComponentProperties componentProperties)
@Autowired public void setScreenBuilders(ScreenBuilders screenBuilders)
@Autowired public void setAccessManager(io.jmix.core.AccessManager accessManager)
protected boolean isPermitted()
BaseAction
isPermitted
in class BaseAction
public void actionPerform(Component component)
Action
actionPerform
in interface Action
actionPerform
in class BaseAction
component
- invoking componentpublic void execute()
execute
in interface Action.ExecutableAction