Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

info.magnolia.ui.model.action.CommandActionBase and its definition counterpart CommandActionDefinition will allow  allows for easier easy use of commands by the App developers . The Command action class will provide a by handling much of the boilerplate code they would otherwise need to write.

In most cases it's just a matter of configuration. You define a marker interface extending CommandActionDefinition and bind CommandActionBase to it. The CommandActionDefinition will need to define at least the name of the command to execute, optionally it can define a catalog which otherwise

will use the default value meaning that the command to be executed will be looked for in the default registered catalog of commands. Further parameters can be added in the param subfolder and/or my subclassing CommandActionDefinition as the example below illustrates

Image Added

CommandActionBase provides a Map<String, Object> buildParams(final Node node) method which builds a map of parameters which will be passed to the current command for execution. Called It is called by the constructor.

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.

  • Context.ATTRIBUTE_REPOSITORY = current node's workspace name
  • Context.ATTRIBUTE_UUID = current node's identifier
  • Context.ATTRIBUTE_PATH = current node's path

It will also provide a getCommandsManager() method which will return an instance of CommandsManager to be used for action execution. Typically the execute() method of a subclass action will do something like the following 

...

Subclasses can override this method to add further parameters to the command execution. E.g. in the ActivationAction class

 protected Map<String, Object> buildParams(final Node node) {
     Map<String, Object> params = super.buildParams(node);
     params.put(Context.ATTRIBUTE_RECURSIVE, getDefinition().isRecursive());
     return params;
 }

Proposals for future goals (not to be implemented in this sprint):

...