Class ActionControlTag

  • All Implemented Interfaces:
    ActionData, ConditionalTag, IconSupport, org.apache.commons.jelly.Tag
    Direct Known Subclasses:
    MenuItemTag, ToolButtonTag

    public abstract class ActionControlTag
    extends AbstractActionDataTag

    Definition of an abstract base class for tag handler classes that create controls, which can be associated with actions.

    This class provides basic functionality for defining an action aware control. Concrete sub classes will deal with specific controls like menu items or toolbar buttons.

    This tag handler class supports two different ways of defining a control:

    • All action related properties (like a text, an icon, a tool tip etc.) can be directly set using the same properties as supported by the base class AbstractActionDataTag.
    • A reference to an action can be specified. Then the newly created control will be associated with this action and obtain its properties from there.

    In addition of the attributes defined by the base class the following attributes are supported by this tag handler class:

    Attribute Description Optional
    actionName If this attribute is set, an action with this name will be looked up, and this control will be associated with this action. In this case the values of other attributes defining action related properties will be ignored because these properties are directly obtained from the specified action. depends
    checked A boolean flag that determines whether the control to create should have checked semantics. This will be evaluated by concrete sub classes, which can then create specific control instances, e.g. checkbox menu items or toggle buttons. yes

    Version:
    $Id: ActionControlTag.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Constructor Detail

      • ActionControlTag

        public ActionControlTag()
    • Method Detail

      • getActionName

        public String getActionName()
        Returns the name of the associated action.
        Returns:
        the action name
      • setActionName

        public void setActionName​(String actionName)
        Setter method for the actionName attribute.
        Parameters:
        actionName - the attribute value
      • isChecked

        public boolean isChecked()
        Returns the value of the checked flag.
        Returns:
        the checked flag
      • setChecked

        public void setChecked​(boolean checked)
        Setter method for the checked attribute.
        Parameters:
        checked - the attribute value
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this tag. This implementation checks the provided attributes and either calls createActionControl() or createElementHandler() to create the concrete control.
        Specified by:
        process in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if this tag is used in an invalid way
        FormBuilderException - if an error occurs
      • getTask

        public Object getTask()
        Dummy implementation of this interface method. This implementation always returns null.
        Returns:
        the task for the action
      • getContainerClass

        protected abstract Class<?> getContainerClass()
        Returns the class of the nesting container tag. This method must be defined in concrete sub classes. It is invoked by the implementation of the process() method to find the tag handler class this tag must be nested inside (e.g. a menu item tag must be placed in the body of a menu tag). The class returned here must also implement the ActionContainer interface.
        Returns:
        the nesting container tag class
      • createActionControl

        protected abstract void createActionControl​(ActionManager manager,
                                                    FormAction action,
                                                    Object parent)
                                             throws FormActionException
        Creates a control and associates it with the given action. This method is invoked if the actionName attribute is defined. It must be implemented in a concrete sub class to perform the necessary steps to create the control based on the properties of the given action.
        Parameters:
        manager - the action manager
        action - the action this control should be associated with
        parent - the parent container to which the new control should be added
        Throws:
        FormActionException - if an error occurs
      • createElementHandler

        protected abstract ComponentHandler<?> createElementHandler​(ActionManager manager,
                                                                    ActionData data,
                                                                    Object parent)
                                                             throws FormActionException
        Creates a control based on the given action data object. This method is invoked if the actionName attribute is not defined. A concrete sub class must implement it to perform all necessary steps for creating the control based on the given properties. The return value is a component handler instance that will be stored in the current builder data object. From there it can be accessed, e.g. for registering event handlers.
        Parameters:
        manager - the action manager
        data - the action data object
        parent - the parent container to which the new control should be added
        Returns:
        a component handler representing the newly created control
        Throws:
        FormActionException - if an error occurs
      • getActionBuilder

        protected ActionBuilder getActionBuilder()
        Returns a reference to the current ActionBuilder instance. This instance is expected to be placed in the Jelly context.
        Returns:
        the current action builder
      • getActionManager

        protected ActionManager getActionManager()
        Convenience method for obtaining a reference to the current ActionManager.
        Returns:
        the current action manager