info.magnolia.ui.framework.action
Class AbstractCommandAction<D extends CommandActionDefinition>

java.lang.Object
  extended by info.magnolia.ui.api.action.AbstractAction<D>
      extended by info.magnolia.ui.framework.action.AbstractMultiItemAction<D>
          extended by info.magnolia.ui.framework.action.AbstractCommandAction<D>
Type Parameters:
D - CommandActionDefinition.
All Implemented Interfaces:
Action
Direct Known Subclasses:
ActivationAction, DeleteAction, ExportAction

public class AbstractCommandAction<D extends CommandActionDefinition>
extends AbstractMultiItemAction<D>

Base action supporting execution of commands.


Field Summary
static String COMMAND_RESULT
           
 
Constructor Summary
AbstractCommandAction(D definition, JcrItemAdapter item, info.magnolia.commands.CommandsManager commandsManager, UiContext uiContext, info.magnolia.i18nsystem.SimpleTranslator i18n)
           
AbstractCommandAction(D definition, List<JcrItemAdapter> items, info.magnolia.commands.CommandsManager commandsManager, UiContext uiContext, info.magnolia.i18nsystem.SimpleTranslator i18n)
           
 
Method Summary
protected  Map<String,Object> buildParams(javax.jcr.Item jcrItem)
          Builds a map of parameters which will be passed to the current command for execution.
protected  void executeOnItem(JcrItemAdapter item)
          Handles the retrieval of the Command instance defined in the CommandActionDefinition associated with this action and then performs the actual command execution.
protected  info.magnolia.commands.chain.Command getCommand()
           
 info.magnolia.commands.CommandsManager getCommandsManager()
           
protected  String getFailureMessage()
          Returns the message to display, if the execution fails on at least ONE item.
 Map<String,Object> getParams()
           
protected  String getSuccessMessage()
          Returns the message to display, if the execution succeeds on ALL items.
protected  void onError(Exception e)
          Class that implement CommansActionBase should use this in order to perform tasks or notification in case of error.
protected  void onPostExecute()
          Post Command Execution.
protected  void onPreExecute()
          Pre Command Execution.
 
Methods inherited from class info.magnolia.ui.framework.action.AbstractMultiItemAction
execute, getCurrentItem, getErrorNotification, getFailedItems, getItemComparator, getItems, getSortedItems, getUiContext, setCurrentItem
 
Methods inherited from class info.magnolia.ui.api.action.AbstractAction
getDefinition
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMMAND_RESULT

public static final String COMMAND_RESULT
See Also:
Constant Field Values
Constructor Detail

AbstractCommandAction

public AbstractCommandAction(D definition,
                             JcrItemAdapter item,
                             info.magnolia.commands.CommandsManager commandsManager,
                             UiContext uiContext,
                             info.magnolia.i18nsystem.SimpleTranslator i18n)

AbstractCommandAction

public AbstractCommandAction(D definition,
                             List<JcrItemAdapter> items,
                             info.magnolia.commands.CommandsManager commandsManager,
                             UiContext uiContext,
                             info.magnolia.i18nsystem.SimpleTranslator i18n)
Method Detail

buildParams

protected Map<String,Object> buildParams(javax.jcr.Item jcrItem)
Builds a map of parameters which will be passed to the current command for execution. Called by onPreExecute(). Default implementation returns a map containing the parameters defined at CommandActionDefinition.getParams(). It also adds the following parameters with values retrieved from the passed node. Subclasses can override this method to add further parameters to the command execution. E.g.
 protected Map<String, Object> buildParams(final Node node) {
     Map<String, Object> params = super.buildParams(node);
     params.put(Context.ATTRIBUTE_RECURSIVE, getDefinition().isRecursive());
     return params;
 }
 


getParams

public final Map<String,Object> getParams()
Returns:
the immutable map of parameters to be used for command execution.
See Also:
buildParams(javax.jcr.Item)

getCommandsManager

public final info.magnolia.commands.CommandsManager getCommandsManager()

executeOnItem

protected void executeOnItem(JcrItemAdapter item)
                      throws ActionExecutionException
Handles the retrieval of the Command instance defined in the CommandActionDefinition associated with this action and then performs the actual command execution.

Specified by:
executeOnItem in class AbstractMultiItemAction<D extends CommandActionDefinition>
Throws:
ActionExecutionException - if no command is found or if command execution throws an exception.

onPreExecute

protected void onPreExecute()
                     throws Exception
Pre Command Execution. Class that implement CommansActionBase should use this in order to perform pre Command Tasks. When overriding make sure to call super to build the parameter map.

Throws:
Exception

onPostExecute

protected void onPostExecute()
                      throws Exception
Post Command Execution. Class that implement CommansActionBase should use this in order to perform post Command Tasks.

Throws:
Exception

onError

protected void onError(Exception e)
Class that implement CommansActionBase should use this in order to perform tasks or notification in case of error.


getCommand

protected info.magnolia.commands.chain.Command getCommand()
Returns:
current command.

getSuccessMessage

protected String getSuccessMessage()
Description copied from class: AbstractMultiItemAction
Returns the message to display, if the execution succeeds on ALL items. May return null, if the implementing action handles the user notification on its own.

Specified by:
getSuccessMessage in class AbstractMultiItemAction<D extends CommandActionDefinition>

getFailureMessage

protected String getFailureMessage()
Description copied from class: AbstractMultiItemAction
Returns the message to display, if the execution fails on at least ONE item. May return null, if the implementing action handles the user notification on its own.

Specified by:
getFailureMessage in class AbstractMultiItemAction<D extends CommandActionDefinition>


Copyright © 2013 Magnolia International Ltd.. All Rights Reserved.