Class CreateAction<E>
- All Implemented Interfaces:
AdjustWhenScreenReadOnly
,ExecutableAction
,ScreenOpeningAction
,SecuredAction
,TargetAction<ListDataComponent<E>>
,Action
-
Field Summary
Modifier and TypeFieldDescriptionprotected AccessManager
protected DialogWindowBuilders
static final String
protected OpenMode
protected ActionScreenInitializer
protected ScreenNavigators
Fields inherited from class io.jmix.flowui.action.list.ListDataComponentAction
selectionListenerRegistration, target
Fields inherited from class io.jmix.flowui.action.SecuredBaseAction
enabledByUiPermissions, visibleByUiPermissions
Fields inherited from class io.jmix.flowui.kit.action.BaseAction
enabledExplicitly, visibleExplicitly
Fields inherited from class io.jmix.flowui.kit.action.AbstractAction
description, enabled, eventBus, icon, id, shortcutCombination, text, variant, visible
Fields inherited from interface io.jmix.flowui.kit.action.Action
PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT, PROP_TEXT, PROP_VARIANT, PROP_VISIBLE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
execute()
Executes the action.Returns the screen open mode if it was set byScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returnsnull
.com.vaadin.flow.router.QueryParameters
com.vaadin.flow.router.RouteParameters
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, otherwise returns null.protected void
protected boolean
protected void
protected void
void
setAccessManager
(AccessManager accessManager) <S extends Screen<?>>
voidsetAfterCloseHandler
(Consumer<DialogWindow.AfterCloseEvent<S>> 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 new entity.void
setDialogWindowBuilders
(DialogWindowBuilders dialogWindowBuilders) protected void
setFlowUiComponentProperties
(FlowUiComponentProperties flowUiComponentProperties) void
setInitializer
(Consumer<E> initializer) Sets the new entity initializer.protected void
setMessages
(Messages messages) void
setNewEntitySupplier
(Supplier<E> newEntitySupplier) Sets the new entity supplier.void
setOpenMode
(OpenMode openMode) Sets the screen open mode.void
setQueryParameters
(com.vaadin.flow.router.QueryParameters queryParameters) Sets query parameters that should be used in the URL.void
setRouteParameters
(com.vaadin.flow.router.RouteParameters routeParameters) Sets route parameters that should be used in the route template.void
setScreenClass
(Class<? extends Screen> screenClass) Sets the editor screen class.void
setScreenId
(String screenId) Sets the editor screen id.void
setScreenNavigators
(ScreenNavigators screenNavigators) 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.<S extends Screen<?>>
CreateAction<E>withAfterCloseHandler
(Consumer<DialogWindow.AfterCloseEvent<S>> afterCloseHandler) withAfterCommitHandler
(Consumer<E> afterCommitHandler) withInitializer
(Consumer<E> initializer) withNewEntitySupplier
(Supplier<E> newEntitySupplier) withOpenMode
(OpenMode openMode) withQueryParameters
(com.vaadin.flow.router.QueryParameters queryParameters) withRouteParameters
(com.vaadin.flow.router.RouteParameters routeParameters) withScreenClass
(Class<? extends Screen> screenClass) withScreenId
(String screenId) withTransformation
(Function<E, E> transformation) Methods inherited from class io.jmix.flowui.action.list.ListDataComponentAction
actionPerform, attachSelectionListener, checkTarget, getTarget, onSelectionChange, setTarget, withEnabled, withEnabledByUiPermissions, withHandler, withIcon, withIcon, withShortcutCombination, withTarget, withText, withTitle, withVariant, withVisible, withVisibleByUiPermissions
Methods inherited from class io.jmix.flowui.action.SecuredBaseAction
isEnabledByUiPermissions, isVisibleByUiPermissions, refreshState, setEnabledByUiPermissions, setVisibleByUiPermissions
Methods inherited from class io.jmix.flowui.kit.action.BaseAction
addActionPerformedListener, isApplicable, setEnabled, setEnabledInternal, setVisible, setVisibleInternal
Methods inherited from class io.jmix.flowui.kit.action.AbstractAction
addPropertyChangeListener, firePropertyChange, getDescription, getEventBus, getIcon, getId, getShortcutCombination, getText, getVariant, hasListener, isEnabled, isVisible, setDescription, setIcon, setShortcutCombination, setText, setVariant
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.jmix.flowui.kit.action.Action
actionPerform, addPropertyChangeListener, getDescription, getIcon, getId, getShortcutCombination, getText, getVariant, isEnabled, isVisible, refreshState, setDescription, setEnabled, setIcon, setShortcutCombination, setText, setVariant, setVisible
Methods inherited from interface io.jmix.flowui.action.AdjustWhenScreenReadOnly
isDisabledWhenScreenReadOnly
-
Field Details
-
ID
- See Also:
-
dialogWindowBuilders
-
accessManager
-
screenInitializer
-
newEntitySupplier
-
initializer
-
afterCommitHandler
-
transformation
-
openMode
-
-
Constructor Details
-
CreateAction
public CreateAction() -
CreateAction
-
-
Method Details
-
initAction
protected void initAction()- Overrides:
initAction
in classListDataComponentAction<CreateAction<E>,
E>
-
getOpenMode
Description copied from interface:ScreenOpeningAction
Returns the screen open mode if it was set byScreenOpeningAction.setOpenMode(OpenMode)
or in the screen XML, otherwise returnsnull
.- Specified by:
getOpenMode
in interfaceScreenOpeningAction
-
setOpenMode
Description copied from interface:ScreenOpeningAction
Sets the screen open mode.- Specified by:
setOpenMode
in interfaceScreenOpeningAction
- 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 interfaceScreenOpeningAction
-
setScreenId
Sets the editor screen id.- Specified by:
setScreenId
in interfaceScreenOpeningAction
- 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 interfaceScreenOpeningAction
-
setScreenClass
Sets the editor screen class.- Specified by:
setScreenClass
in interfaceScreenOpeningAction
- Parameters:
screenClass
- the screen class to set
-
getRouteParameters
@Nullable public com.vaadin.flow.router.RouteParameters getRouteParameters()- Specified by:
getRouteParameters
in interfaceScreenOpeningAction
- Returns:
- route parameters or
null
if not set
-
setRouteParameters
public void setRouteParameters(@Nullable com.vaadin.flow.router.RouteParameters routeParameters) Description copied from interface:ScreenOpeningAction
Sets route parameters that should be used in the route template.Note that route parameters are set if the editor is opened in
OpenMode.NAVIGATION
.- Specified by:
setRouteParameters
in interfaceScreenOpeningAction
- Parameters:
routeParameters
- route parameters to set- See Also:
-
Route
-
getQueryParameters
@Nullable public com.vaadin.flow.router.QueryParameters getQueryParameters()- Specified by:
getQueryParameters
in interfaceScreenOpeningAction
- Returns:
- query parameters or
null
if not set
-
setQueryParameters
public void setQueryParameters(@Nullable com.vaadin.flow.router.QueryParameters queryParameters) Description copied from interface:ScreenOpeningAction
Sets query parameters that should be used in the URL.Note that query parameters are set if the editor is opened in
OpenMode.NAVIGATION
.- Specified by:
setQueryParameters
in interfaceScreenOpeningAction
- Parameters:
queryParameters
- query parameters to set
-
setAfterCloseHandler
public <S extends Screen<?>> void setAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<S>> afterCloseHandler) Description copied from interface:ScreenOpeningAction
Sets the handler to be invoked when the editor screen closes.Note that handler is invoked if the editor is opened in
OpenMode.DIALOG
mode.The preferred way to set the handler is using a controller method annotated with
Install
, e.g.:@Install(to = "petsTable.view", subject = "afterCloseHandler") protected void petsTableViewAfterCloseHandler(AfterCloseEvent event) { if (event.closedWith(StandardOutcome.COMMIT)) { System.out.println("Committed"); } }
- Specified by:
setAfterCloseHandler
in interfaceScreenOpeningAction
- Type Parameters:
S
- screen type- Parameters:
afterCloseHandler
- handler to set
-
setInitializer
Sets the new entity initializer. The initializer accepts the new entity instance and can perform its initialization.Note that initializer is invoked if the editor is opened in
OpenMode.DIALOG
mode.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"); }
-
setAfterCommitHandler
Sets the handler to be invoked when the editor screen commits the new entity.Note that handler is invoked if the editor is opened in
OpenMode.DIALOG
mode.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); }
-
setTransformation
Sets the function to transform the committed in the editor screen entity before setting it to the target data container.Note that transformation function is invoked if the editor is opened in
OpenMode.DIALOG
mode.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); }
-
setNewEntitySupplier
Sets the new entity supplier. The supplier should return a new entity instance.Note that supplier is invoked if the editor is opened in
OpenMode.DIALOG
mode.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; }
-
setMessages
-
setFlowUiComponentProperties
@Autowired protected void setFlowUiComponentProperties(FlowUiComponentProperties flowUiComponentProperties) -
setAccessManager
-
setDialogWindowBuilders
-
isPermitted
protected boolean isPermitted()- Overrides:
isPermitted
in classSecuredBaseAction
-
execute
public void execute()Executes the action.- Specified by:
execute
in interfaceExecutableAction
-
openDialog
protected void openDialog() -
withScreenId
- See Also:
-
withScreenClass
- See Also:
-
withRouteParameters
public CreateAction<E> withRouteParameters(@Nullable com.vaadin.flow.router.RouteParameters routeParameters) - See Also:
-
withQueryParameters
public CreateAction<E> withQueryParameters(@Nullable com.vaadin.flow.router.QueryParameters queryParameters) - See Also:
-
withOpenMode
- See Also:
-
withAfterCloseHandler
public <S extends Screen<?>> CreateAction<E> withAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<S>> afterCloseHandler) - See Also:
-
withAfterCommitHandler
- See Also:
-
withTransformation
- See Also:
-
withInitializer
- See Also:
-
withNewEntitySupplier
- See Also:
-