org.pm4j.core.pm
Interface PmCommand

All Superinterfaces:
java.lang.Comparable<PmObject>, PmObject
All Known Implementing Classes:
PmCommandGroup, PmCommandImpl, PmCommandNaviBack, PmCommandProxy, PmCommandSeparator, PmContentChangeCommand, PmListAddItemCommand, PmListRemoveItemCommand, PmTableColImpl.CmdSortPm, PmValueChangeCommand

public interface PmCommand
extends PmObject

A user interface command.

Author:
olaf boede

Nested Class Summary
static class PmCommand.CmdKind
           
static class PmCommand.CommandSet
           
static class PmCommand.CommandState
           
 
Field Summary
 
Fields inherited from interface org.pm4j.core.pm.PmObject
STYLE_CLASS_DISABLED, STYLE_CLASS_ERROR, STYLE_CLASS_INFO, STYLE_CLASS_REQUIRED, STYLE_CLASS_WARN
 
Method Summary
 void addCommandDecorator(PmCommandDecorator commandDecorator)
           
 PmCommand doIt()
          Does the operation.
 PmObject doItReturnNextDlgPm()
          Executes the command.
 java.lang.String doItReturnString()
          Interface for web frameworks like JSF.
 void doItReturnVoid()
          Command call with void return type.
 PmCommand.CmdKind getCmdKind()
           
 PmCommand.CommandState getCommandState()
           
 org.pm4j.navi.NaviLink getNaviLink()
          Provides an optional link to a navigation target.
 java.util.List<PmCommand> getParentCommands()
          A command may be nested in a hierarchy of other parent commands (command groups).
 PmCommand getUndoCommand()
          Provides an instance that may undo the effect of this command.
 boolean isRequiresValidValues()
           
 
Methods inherited from interface org.pm4j.core.pm.PmObject
accept, canSetPmTitle, compareTo, getPmConversation, getPmIconPath, getPmName, getPmParent, getPmProperty, getPmRelativeName, getPmShortTitle, getPmStyleClasses, getPmTitle, getPmTooltip, isPmEnabled, isPmReadonly, isPmValid, isPmVisible, setPmEnabled, setPmParent, setPmProperty, setPmTitle, setPmVisible
 

Method Detail

doIt

PmCommand doIt()
Does the operation.

It internally clones this command instance and perfroms the operation using the cloned command.
This prototype pattern approach allows to store execution time specific values within the command (E.g. navigation links, values, an undo-command).

Returns the command instance (clone) that performed the operation.

Any error messages are reported as error messages.

Returns:
The command clone that performed the operation.

doItReturnNextDlgPm

PmObject doItReturnNextDlgPm()
Executes the command. If the command provides a next dialog (E.g. in case of wizard page flows), the PM of the next page will be returned.

Returns:
The PM of the next page to show.

getUndoCommand

PmCommand getUndoCommand()
Provides an instance that may undo the effect of this command.

A command is 'undo-able' when this method returns null.

Returns:
The command that can undo the effect of this command or null.

doItReturnString

java.lang.String doItReturnString()
Interface for web frameworks like JSF.

Returns:
Implementation dependent. Typically "myPm.cmdDoSomeWork.success" or "myPm.cmdDoSomeWork.failed".

doItReturnVoid

void doItReturnVoid()
Command call with void return type. Used to support some ui frameworks (such as a4j) that need void signatures for actions.


getCmdKind

PmCommand.CmdKind getCmdKind()
Returns:
The PmCommand.CmdKind of this command item.

getParentCommands

java.util.List<PmCommand> getParentCommands()
A command may be nested in a hierarchy of other parent commands (command groups). This method returns this set. The first list item is the root group. The last list item is the nearest parent.

Returns:
The parent command list. In case of no parents an empty list, never null.

getNaviLink

org.pm4j.navi.NaviLink getNaviLink()
Provides an optional link to a navigation target.

Is usually provided by commands that just perform a static navigation.

Some commands calculate their navigation target when they get executed. In this case only the result of the doIt() call provides the correct navigation link.

Returns:
The navigation link or null.

isRequiresValidValues

boolean isRequiresValidValues()
Returns:
true when the command should fail when there are invalid values within the current session.

addCommandDecorator

void addCommandDecorator(PmCommandDecorator commandDecorator)
Parameters:
commandDecorator - The decorator to add to the command execution logic.

getCommandState

PmCommand.CommandState getCommandState()
Returns:
The command (execution) state.