Class CreateAction<E>
- All Implemented Interfaces:
AdjustWhenViewReadOnly,ExecutableAction,SecuredAction,TargetAction<ListDataComponent<E>>,ViewOpeningAction,Action,HasShortcutCombination
- Direct Known Subclasses:
EntityInspectorCreateAction
-
Nested Class Summary
Nested classes/interfaces inherited from class io.jmix.flowui.action.SecuredBaseAction
SecuredBaseAction.EnabledRuleNested classes/interfaces inherited from interface io.jmix.flowui.action.ViewOpeningAction
ViewOpeningAction.QueryParametersProvider, ViewOpeningAction.RouteParametersProvider -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AccessManagerprotected DialogWindowsstatic final Stringprotected OpenModeprotected ActionViewInitializerprotected ViewNavigatorsFields inherited from class io.jmix.flowui.action.list.ListDataComponentAction
selectionListenerRegistration, targetFields inherited from class io.jmix.flowui.action.SecuredBaseAction
enabledByUiPermissions, enabledRules, visibleByUiPermissionsFields inherited from class io.jmix.flowui.kit.action.BaseAction
enabledExplicitly, visibleExplicitlyFields inherited from class io.jmix.flowui.kit.action.AbstractAction
description, enabled, eventBus, icon, id, shortcutCombination, text, variant, visibleFields inherited from interface io.jmix.flowui.kit.action.Action
PROP_DESCRIPTION, PROP_ENABLED, PROP_ICON, PROP_SHORTCUT_COMBINATION, PROP_TEXT, PROP_VARIANT, PROP_VISIBLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute()Executes the action.Returns the view open mode if it was set byViewOpeningAction.setOpenMode(OpenMode)or in the view XML, otherwise returnsnull.Returns the detail view class if it was set bysetViewClass(Class)or in the view XML.Returns the detail view id if it was set bysetViewId(String)or in the view XML, otherwise returns null.protected voidprotected booleanprotected voidnavigate()protected voidvoidsetAccessManager(AccessManager accessManager) <V extends View<?>>
voidsetAfterCloseHandler(Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) Sets the handler to be invoked when the detail view closes.voidsetAfterSaveHandler(Consumer<E> afterSaveHandler) Sets the handler to be invoked when the detail view saves the new entity.voidsetDialogWindowBuilders(DialogWindows dialogWindows) voidsetInitializer(Consumer<E> initializer) Sets the new entity initializer.protected voidsetMessages(Messages messages) voidsetNewEntitySupplier(Supplier<E> newEntitySupplier) Sets the new entity supplier.voidsetOpenMode(OpenMode openMode) Sets the view open mode.voidSets query parameters provider that returns query parameters that should be used in the URL.voidSets route parameters provider that returns route parameters that should be used in the route template.voidsetTransformation(Function<E, E> transformation) Sets the function to transform the saved in the detail view entity before setting it to the target data container.protected voidsetUiComponentProperties(UiComponentProperties uiComponentProperties) voidsetViewClass(Class<? extends View> viewClass) Sets the detail view class.voidSets the detail view id.voidsetViewNavigators(ViewNavigators viewNavigators) <V extends View<?>>
CreateAction<E>withAfterCloseHandler(Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) withAfterSaveHandler(Consumer<E> afterSaveHandler) withInitializer(Consumer<E> initializer) withNewEntitySupplier(Supplier<E> newEntitySupplier) withOpenMode(OpenMode openMode) withTransformation(Function<E, E> transformation) withViewClass(Class<? extends View> viewClass) withViewId(String viewId) Methods inherited from class io.jmix.flowui.action.list.ListDataComponentAction
actionPerform, attachSelectionListener, checkTarget, checkTargetItems, getTarget, onSelectionChange, setTarget, withEnabled, withEnabledByUiPermissions, withHandler, withIcon, withIcon, withShortcutCombination, withTarget, withText, withTitle, withVariant, withVisible, withVisibleByUiPermissionsMethods inherited from class io.jmix.flowui.action.SecuredBaseAction
addEnabledRule, isEnabledByRule, isEnabledByUiPermissions, isVisibleByUiPermissions, refreshState, removeEnabledRule, setEnabledByUiPermissions, setVisibleByUiPermissionsMethods inherited from class io.jmix.flowui.kit.action.BaseAction
addActionPerformedListener, isApplicable, setEnabled, setEnabledInternal, setVisible, setVisibleInternalMethods 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, setVariantMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jmix.flowui.kit.action.Action
actionPerform, addPropertyChangeListener, getDescription, getIcon, getId, getText, getVariant, isEnabled, isVisible, refreshState, setDescription, setEnabled, setIcon, setText, setVariant, setVisibleMethods inherited from interface io.jmix.flowui.action.AdjustWhenViewReadOnly
isDisabledWhenViewReadOnlyMethods inherited from interface io.jmix.flowui.kit.component.HasShortcutCombination
getShortcutCombination, setShortcutCombination
-
Field Details
-
ID
- See Also:
-
dialogWindows
-
accessManager
-
viewInitializer
-
newEntitySupplier
-
initializer
-
afterSaveHandler
-
transformation
-
openMode
-
-
Constructor Details
-
CreateAction
public CreateAction() -
CreateAction
-
-
Method Details
-
initAction
protected void initAction()- Overrides:
initActionin classListDataComponentAction<CreateAction<E>,E>
-
getOpenMode
Description copied from interface:ViewOpeningActionReturns the view open mode if it was set byViewOpeningAction.setOpenMode(OpenMode)or in the view XML, otherwise returnsnull.- Specified by:
getOpenModein interfaceViewOpeningAction
-
setOpenMode
Description copied from interface:ViewOpeningActionSets the view open mode.- Specified by:
setOpenModein interfaceViewOpeningAction- Parameters:
openMode- the open mode to set
-
getViewId
Returns the detail view id if it was set bysetViewId(String)or in the view XML, otherwise returns null.- Specified by:
getViewIdin interfaceViewOpeningAction
-
setViewId
Sets the detail view id.- Specified by:
setViewIdin interfaceViewOpeningAction- Parameters:
viewId- the view id to set
-
getViewClass
Returns the detail view class if it was set bysetViewClass(Class)or in the view XML. Otherwise returns null.- Specified by:
getViewClassin interfaceViewOpeningAction
-
setViewClass
Sets the detail view class.- Specified by:
setViewClassin interfaceViewOpeningAction- Parameters:
viewClass- the view class to set
-
getRouteParametersProvider
- Specified by:
getRouteParametersProviderin interfaceViewOpeningAction- Returns:
- route parameters or
nullif not set
-
setRouteParametersProvider
public void setRouteParametersProvider(@Nullable ViewOpeningAction.RouteParametersProvider provider) Description copied from interface:ViewOpeningActionSets route parameters provider that returns route parameters that should be used in the route template.Note that route parameters provider is set if the detail is opened in
OpenMode.NAVIGATION.- Specified by:
setRouteParametersProviderin interfaceViewOpeningAction- Parameters:
provider- route parameters provider to set- See Also:
-
Route
-
getQueryParametersProvider
- Specified by:
getQueryParametersProviderin interfaceViewOpeningAction- Returns:
- query parameters provider or
nullif not set
-
setQueryParametersProvider
public void setQueryParametersProvider(@Nullable ViewOpeningAction.QueryParametersProvider provider) Description copied from interface:ViewOpeningActionSets query parameters provider that returns query parameters that should be used in the URL.Note that query parameters provider is set if the detail is opened in
OpenMode.NAVIGATION.- Specified by:
setQueryParametersProviderin interfaceViewOpeningAction- Parameters:
provider- query parameters provider to set
-
setAfterCloseHandler
public <V extends View<?>> void setAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) Description copied from interface:ViewOpeningActionSets the handler to be invoked when the detail view closes.Note that handler is invoked if the detail is opened in
OpenMode.DIALOGmode.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.SAVE)) { System.out.println("Saved"); } }- Specified by:
setAfterCloseHandlerin interfaceViewOpeningAction- Type Parameters:
V- view 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 detail is opened in
OpenMode.DIALOGmode.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"); } -
setAfterSaveHandler
Sets the handler to be invoked when the detail view saves the new entity.Note that handler is invoked if the detail is opened in
OpenMode.DIALOGmode.The preferred way to set the handler is using a controller method annotated with
Install, e.g.:@Install(to = "petsTable.create", subject = "afterSaveHandler") protected void petsTableCreateAfterSaveHandler(Pet entity) { System.out.println("Created " + entity); } -
setTransformation
Sets the function to transform the saved in the detail view entity before setting it to the target data container.Note that transformation function is invoked if the detail is opened in
OpenMode.DIALOGmode.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 detail is opened in
OpenMode.DIALOGmode.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
-
setUiComponentProperties
-
setAccessManager
-
setDialogWindowBuilders
-
isPermitted
protected boolean isPermitted()- Overrides:
isPermittedin classSecuredBaseAction
-
execute
public void execute()Executes the action.- Specified by:
executein interfaceExecutableAction
-
openDialog
protected void openDialog() -
withViewId
- See Also:
-
withViewClass
- See Also:
-
withRouteParameters
public CreateAction<E> withRouteParameters(@Nullable ViewOpeningAction.RouteParametersProvider provider) -
withQueryParameters
public CreateAction<E> withQueryParameters(@Nullable ViewOpeningAction.QueryParametersProvider provider) -
withOpenMode
- See Also:
-
withAfterCloseHandler
public <V extends View<?>> CreateAction<E> withAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) - See Also:
-
withAfterSaveHandler
- See Also:
-
withTransformation
- See Also:
-
withInitializer
- See Also:
-
withNewEntitySupplier
- See Also:
-