@Component(value="cuba_CreateAction") @Scope(value="prototype") public class CreateAction extends ListAction implements Action.HasOpenType, Action.HasBeforeActionPerformedHandler
Action's behaviour can be customized by providing arguments to constructor, setting properties, or overriding
methods afterCommit(com.haulmont.cuba.core.entity.Entity)
, afterWindowClosed(com.haulmont.cuba.gui.components.Window)
In order to provide your own implementation globally, create a subclass and register it in web-spring.xml
,
for example:
<bean id="cuba_CreateAction" class="com.company.sample.gui.MyCreateAction" scope="prototype"/>Also, use
create()
static methods instead of constructors when creating the action programmatically.Modifier and Type | Class and Description |
---|---|
static interface |
CreateAction.AfterCommitHandler |
static interface |
CreateAction.AfterWindowClosedHandler |
BaseAction.EnabledRule
Action.ActionPerformedEvent, Action.BeforeActionPerformedHandler, Action.HasBeforeActionPerformedHandler, Action.HasOpenType, Action.HasSecurityConstraint, Action.HasTarget, Action.SecuredAction, Action.Status
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACTION_ID |
protected boolean |
addFirst |
protected CreateAction.AfterCommitHandler |
afterCommitHandler |
protected CreateAction.AfterWindowClosedHandler |
afterWindowClosedHandler |
protected Action.BeforeActionPerformedHandler |
beforeActionPerformedHandler |
protected Window.CloseListener |
editorCloseListener |
protected java.util.Map<java.lang.String,java.lang.Object> |
initialValues |
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> |
initialValuesSupplier |
protected Metadata |
metadata |
protected WindowManager.OpenType |
openType |
protected Security |
security |
protected java.lang.String |
windowId |
protected java.util.Map<java.lang.String,java.lang.Object> |
windowParams |
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> |
windowParamsSupplier |
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(ListComponent target)
The simplest constructor.
|
CreateAction(ListComponent target,
WindowManager.OpenType openType)
Constructor that allows to specify how the editor screen opens.
|
CreateAction(ListComponent target,
WindowManager.OpenType openType,
java.lang.String id)
Constructor that allows to specify the action name and how the editor screen opens.
|
Modifier and Type | Method and Description |
---|---|
void |
actionPerform(Component component)
This method is invoked by action owner component.
|
protected void |
afterCommit(Entity entity)
Hook invoked after the editor was committed and closed
|
protected void |
afterWindowClosed(Window window)
Hook invoked always after the editor was closed
|
static CreateAction |
create(ListComponent target)
Creates an action with default id, opening the editor screen in THIS tab.
|
static CreateAction |
create(ListComponent target,
WindowManager.OpenType openType)
Creates an action with default id.
|
static CreateAction |
create(ListComponent target,
WindowManager.OpenType openType,
java.lang.String id)
Creates an action with the given id.
|
protected Entity |
createEntity() |
Action.BeforeActionPerformedHandler |
getBeforeActionPerformedHandler() |
java.util.Map<java.lang.String,java.lang.Object> |
getInitialValues() |
java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> |
getInitialValuesSupplier() |
WindowManager.OpenType |
getOpenType() |
java.lang.String |
getWindowId() |
java.util.Map<java.lang.String,java.lang.Object> |
getWindowParams() |
java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> |
getWindowParamsSupplier() |
protected void |
internalOpenEditor(CollectionDatasource datasource,
Entity newItem,
Datasource parentDs,
java.util.Map<java.lang.String,java.lang.Object> params) |
boolean |
isAddFirst() |
protected boolean |
isPermitted()
Check permissions for Action
|
protected java.util.Map<java.lang.String,java.lang.Object> |
prepareWindowParams() |
void |
setAddFirst(boolean addFirst)
Whether this action will add a new instance to the beginning of the datasource's collection.
|
void |
setAfterCommitHandler(CreateAction.AfterCommitHandler afterCommitHandler) |
void |
setAfterWindowClosedHandler(CreateAction.AfterWindowClosedHandler afterWindowClosedHandler) |
void |
setBeforeActionPerformedHandler(Action.BeforeActionPerformedHandler handler) |
void |
setEditorCloseListener(Window.CloseListener editorCloseListener)
Overwrites default close listener for editor window.
|
void |
setInitialValues(java.util.Map<java.lang.String,java.lang.Object> initialValues) |
void |
setInitialValuesSupplier(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> initialValuesSupplier) |
protected void |
setInitialValuesToItem(Entity item) |
void |
setOpenType(WindowManager.OpenType openType) |
void |
setWindowId(java.lang.String windowId) |
void |
setWindowParams(java.util.Map<java.lang.String,java.lang.Object> windowParams) |
void |
setWindowParamsSupplier(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> windowParamsSupplier) |
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, getDefaultCaption, getDescription, getEventHub, getIcon, getId, getOwner, getOwners, getShortcutCombination, hasSubscriptions, isEnabled, isPrimary, isVisible, removeOwner, removePropertyChangeListener, setCaption, setDescription, setIcon, setIconFromSet, setPrimary, setShortcut, setShortcutCombination
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addOwner, addPropertyChangeListener, getCaption, getDescription, getIcon, getId, getOwner, getOwners, getShortcutCombination, isEnabled, isVisible, refreshState, removeOwner, removePropertyChangeListener, setCaption, setDescription, setEnabled, setIcon, setIconFromSet, setShortcut, setShortcutCombination, setVisible
public static final java.lang.String ACTION_ID
protected WindowManager.OpenType openType
protected java.lang.String windowId
protected java.util.Map<java.lang.String,java.lang.Object> windowParams
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> windowParamsSupplier
protected java.util.Map<java.lang.String,java.lang.Object> initialValues
protected java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> initialValuesSupplier
protected boolean addFirst
protected Metadata metadata
protected Security security
protected CreateAction.AfterCommitHandler afterCommitHandler
protected CreateAction.AfterWindowClosedHandler afterWindowClosedHandler
protected Window.CloseListener editorCloseListener
protected Action.BeforeActionPerformedHandler beforeActionPerformedHandler
public CreateAction(ListComponent target)
target
- component containing this actionpublic CreateAction(ListComponent target, WindowManager.OpenType openType)
target
- component containing this actionopenType
- how to open the editor screenpublic CreateAction(ListComponent target, WindowManager.OpenType openType, java.lang.String id)
target
- component containing this actionopenType
- how to open the editor screenid
- action namepublic static CreateAction create(ListComponent target)
target
- component containing this actionpublic static CreateAction create(ListComponent target, WindowManager.OpenType openType)
target
- component containing this actionopenType
- how to open the editor screenpublic static CreateAction create(ListComponent target, WindowManager.OpenType openType, java.lang.String id)
target
- component containing this actionopenType
- how to open the editor screenid
- action nameprotected boolean isPermitted()
isPermitted
in class BaseAction
public void actionPerform(Component component)
actionPerform
in interface Action
actionPerform
in class BaseAction
component
- component invoking actionprotected Entity createEntity()
protected java.util.Map<java.lang.String,java.lang.Object> prepareWindowParams()
protected void setInitialValuesToItem(Entity item)
protected void internalOpenEditor(CollectionDatasource datasource, Entity newItem, Datasource parentDs, java.util.Map<java.lang.String,java.lang.Object> params)
public WindowManager.OpenType getOpenType()
getOpenType
in interface Action.HasOpenType
public void setOpenType(WindowManager.OpenType openType)
setOpenType
in interface Action.HasOpenType
openType
- editor screen open typepublic java.lang.String getWindowId()
public void setWindowId(java.lang.String windowId)
windowId
- editor screen identifierpublic java.util.Map<java.lang.String,java.lang.Object> getWindowParams()
public void setWindowParams(java.util.Map<java.lang.String,java.lang.Object> windowParams)
windowParams
- editor screen parameterspublic java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> getWindowParamsSupplier()
public void setWindowParamsSupplier(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> windowParamsSupplier)
windowParamsSupplier
- supplier that provides editor screen parameterspublic java.util.Map<java.lang.String,java.lang.Object> getInitialValues()
public void setInitialValues(java.util.Map<java.lang.String,java.lang.Object> initialValues)
initialValues
- map of initial values for attributes of created entitypublic java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> getInitialValuesSupplier()
public void setInitialValuesSupplier(java.util.function.Supplier<java.util.Map<java.lang.String,java.lang.Object>> initialValuesSupplier)
initialValuesSupplier
- supplier that provides map of initial values for attributes of created entitypublic boolean isAddFirst()
public void setAddFirst(boolean addFirst)
ClientConfig.getCreateActionAddsFirst()
protected void afterCommit(Entity entity)
entity
- new committed entity instanceprotected void afterWindowClosed(Window window)
window
- the editor windowpublic void setAfterCommitHandler(CreateAction.AfterCommitHandler afterCommitHandler)
afterCommitHandler
- handler that is invoked after the editor was committed and closedpublic void setAfterWindowClosedHandler(CreateAction.AfterWindowClosedHandler afterWindowClosedHandler)
afterWindowClosedHandler
- handler that is always invoked after the editor closedpublic void setEditorCloseListener(Window.CloseListener editorCloseListener)
editorCloseListener
- new close listenerpublic Action.BeforeActionPerformedHandler getBeforeActionPerformedHandler()
getBeforeActionPerformedHandler
in interface Action.HasBeforeActionPerformedHandler
public void setBeforeActionPerformedHandler(Action.BeforeActionPerformedHandler handler)
setBeforeActionPerformedHandler
in interface Action.HasBeforeActionPerformedHandler