Class CreateAction<E>
- All Implemented Interfaces:
AdjustWhenViewReadOnly,ExecutableAction,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
enabledRulesFields inherited from class io.jmix.flowui.action.ObservableBaseAction
uiObservationSupportFields 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.<V extends View<?>>
Consumer<DialogWindow.AfterCloseEvent<V>> @Nullable OpenModeReturns 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.@Nullable StringReturns 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(@Nullable Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) Sets the handler to be invoked when the detail view closes.voidsetAfterSaveHandler(@Nullable Consumer<E> afterSaveHandler) Sets the handler to be invoked when the detail view saves the new entity.voidsetDialogWindowBuilders(DialogWindows dialogWindows) protected voidvoidsetInitializer(@Nullable Consumer<E> initializer) Sets the new entity initializer.protected voidsetMessages(Messages messages) voidsetNewEntitySupplier(@Nullable Supplier<E> newEntitySupplier) Sets the new entity supplier.voidsetOpenMode(@Nullable OpenMode openMode) Sets the view open mode.voidsetQueryParametersProvider(@Nullable ViewOpeningAction.QueryParametersProvider provider) Sets query parameters provider that returns query parameters that should be used in the URL.voidsetRouteParametersProvider(@Nullable ViewOpeningAction.RouteParametersProvider provider) Sets route parameters provider that returns route parameters that should be used in the route template.voidsetTransformation(@Nullable 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(@Nullable Class<? extends View> viewClass) Sets the detail view class.<V extends View<?>>
voidsetViewConfigurer(@Nullable Consumer<V> viewConfigurer) Sets the view configurer.voidSets the detail view id.voidsetViewNavigators(ViewNavigators viewNavigators) <V extends View<?>>
CreateAction<E> withAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) withAfterSaveHandler(@Nullable Consumer<E> afterSaveHandler) withInitializer(@Nullable Consumer<E> initializer) withNewEntitySupplier(@Nullable Supplier<E> newEntitySupplier) withOpenMode(@Nullable OpenMode openMode) withQueryParameters(@Nullable ViewOpeningAction.QueryParametersProvider provider) withRouteParameters(@Nullable ViewOpeningAction.RouteParametersProvider provider) withTransformation(@Nullable Function<E, E> transformation) withViewClass(@Nullable Class<? extends View> viewClass) <V extends View<?>>
CreateAction<E> withViewConfigurer(@Nullable Consumer<V> viewConfigurer) withViewId(@Nullable String viewId) Methods inherited from class io.jmix.flowui.action.list.ListDataComponentAction
actionPerform, attachSelectionListener, checkTarget, checkTargetItems, getTarget, onSelectionChange, setTarget, withTargetMethods inherited from class io.jmix.flowui.action.SecuredBaseAction
addEnabledRule, isEnabledByRule, refreshState, removeEnabledRuleMethods inherited from class io.jmix.flowui.action.ObservableBaseAction
getUiObservationSupportMethods inherited from class io.jmix.flowui.kit.action.BaseAction
addActionPerformedListener, isApplicable, self, setEnabled, setEnabledInternal, setVisible, setVisibleInternal, withDescription, withEnabled, withHandler, withIcon, withShortcutCombination, withText, withVariant, withVisibleMethods inherited from class io.jmix.flowui.kit.action.AbstractAction
addPropertyChangeListener, firePropertyChange, getDescription, getEventBus, getIcon, getIconComponent, getId, getShortcutCombination, getText, getVariant, hasListener, isEnabled, isVisible, setDescription, setIcon, setIconComponent, 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, getIconComponent, getId, getText, getVariant, isEnabled, isVisible, refreshState, setDescription, setEnabled, setIcon, setIconComponent, 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:
-
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
-
getAfterCloseHandler
- Specified by:
getAfterCloseHandlerin interfaceViewOpeningAction
-
setViewConfigurer
Description copied from interface:ViewOpeningActionSets the view configurer. Use the configurer if you need to provide parameters to the opened view through setters.The preferred way to set the configurer is using a controller method annotated with
Install, e.g.:@Install(to = "petsTable.view", subject = "viewConfigurer") protected void petsTableViewConfigurer(View<?> view) { view.setSomeParameter(someValue); }- Specified by:
setViewConfigurerin interfaceViewOpeningAction
-
getViewConfigurer
- Specified by:
getViewConfigurerin interfaceViewOpeningAction
-
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"); } -
getInitializer
-
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); } -
getAfterSaveHandler
-
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); } -
getTransformation
-
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; } -
getNewEntitySupplier
-
setMessages
-
setIcons
-
setUiComponentProperties
-
setAccessManager
-
setDialogWindowBuilders
-
isPermitted
protected boolean isPermitted()- Overrides:
isPermittedin classSecuredBaseAction<CreateAction<E>>
-
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) - See Also:
-
withQueryParameters
public CreateAction<E> withQueryParameters(@Nullable ViewOpeningAction.QueryParametersProvider provider) - See Also:
-
withOpenMode
- See Also:
-
withAfterCloseHandler
public <V extends View<?>> CreateAction<E> withAfterCloseHandler(@Nullable Consumer<DialogWindow.AfterCloseEvent<V>> afterCloseHandler) - See Also:
-
withViewConfigurer
- See Also:
-
withAfterSaveHandler
- See Also:
-
withTransformation
- See Also:
-
withInitializer
- See Also:
-
withNewEntitySupplier
- See Also:
-