Class AbstractActionDataTag

  • All Implemented Interfaces:
    ActionData, ConditionalTag, IconSupport, org.apache.commons.jelly.Tag
    Direct Known Subclasses:
    ActionControlTag, ActionDataTag, ActionTag

    public abstract class AbstractActionDataTag
    extends FormBaseTag
    implements ActionData, IconSupport

    An abstract base class for tag handler classes that need to deal with action objects and their properties.

    This base class provides all functionality for managing an action's properties. These properties can be set using various setter methods. They are accessed through the implemented ActionData interface.

    The following table lists all supported attributes:

    Attribute Description Optional
    text Directly defines the text of this action. yes
    textres Defines the action's text from a text resource. yes
    resgrp Allows specifying a resource group. This group will be used when resolving the resources for the text, the mnemonic, and the tool tip (unless for the tool tip a separate group is defined). yes
    mnemonic Directly sets the mnemonic key. yes
    mnemonicres Allows to specify a resource ID from which the mnemonic will be obtained. yes
    tooltip Directly sets the tooltip for this action. yes
    tooltipres Allows specifying a resource ID for this action's tool tip. yes
    acceleratorDef Sets the accelerator for this action. This attribute expects a string representation of an accelerator that can be parsed by the Accelerator.parse(String) method. yes
    acceleratorRef With this attribute a reference to an Accelerator object can be specified. This object is searched in the current bean context. The attributes acceleratorDef and acceleratorRef are mutual exclusive. yes

    Because this tag handler class also implements the IconSupport interface an <icon> tag can occur in the body.

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

      • AbstractActionDataTag

        public AbstractActionDataTag()
        Creates a new instance of ActionDataTag and initializes it.
    • Method Detail

      • setText

        public void setText​(String t)
        Setter method of the text attribute.
        Parameters:
        t - the attribute value
      • setTextres

        public void setTextres​(String r)
        Setter method for the textres attribute.
        Parameters:
        r - the attribute value
      • setResgrp

        public void setResgrp​(String s)
        Setter method for the resgrp attribute.
        Parameters:
        s - the attribute value
      • setMnemonic

        public void setMnemonic​(String s)
        Setter method for the mnemonic attribute.
        Parameters:
        s - the attribute value
      • setMnemonicres

        public void setMnemonicres​(String s)
        Setter method for the mnemonicres attribute.
        Parameters:
        s - the attribute value
      • setTooltip

        public void setTooltip​(String s)
        Setter method for the tooltip attribute.
        Parameters:
        s - the attribute value
      • setTooltipres

        public void setTooltipres​(String s)
        Setter method for the tooltipres attribute.
        Parameters:
        s - the attribute value
      • setIcon

        public void setIcon​(Object icon)
        Sets the icon for this action.
        Specified by:
        setIcon in interface IconSupport
        Parameters:
        icon - the icon
      • getIcon

        public Object getIcon()
        Returns the icon for this action.
        Specified by:
        getIcon in interface ActionData
        Returns:
        the icon
      • getMnemonicKey

        public int getMnemonicKey()
        Returns the mnemonic for this action.
        Specified by:
        getMnemonicKey in interface ActionData
        Returns:
        the mnemonic
      • getText

        public String getText()
        Returns this action's text.
        Specified by:
        getText in interface ActionData
        Returns:
        the text
      • getToolTip

        public String getToolTip()
        Returns the text for this action's tool tip.
        Specified by:
        getToolTip in interface ActionData
        Returns:
        the tool tip
      • getName

        public String getName()
        Returns the name of this component.
        Specified by:
        getName in interface ActionData
        Returns:
        the name
      • setName

        public void setName​(String name)
        Sets the name of this component. The concrete meaning of this name is determined by derived classes.
        Parameters:
        name - the name
      • getAcceleratorDef

        public String getAcceleratorDef()
        Returns the accelerator definition.
        Returns:
        the accelerator definition
      • setAcceleratorDef

        public void setAcceleratorDef​(String acceleratorDef)
        Set method of the acceleratorDef attribute. Here the string representation of an accelerator can be set. It will be used for obtaining a corresponding Accelerator instance.
        Parameters:
        acceleratorDef - the accelerator definition as string
        See Also:
        Accelerator.parse(String)
      • getAcceleratorRef

        public String getAcceleratorRef()
        Returns the name of a variable to be used as accelerator.
        Returns:
        the name of an accelerator variable
      • setAcceleratorRef

        public void setAcceleratorRef​(String acceleratorRef)
        Set method of the acceleratorRef attribute. Here the name of a variable can be specified that should be used as accelerator. The tag will look up this variable in the current bean context.
        Parameters:
        acceleratorRef - the accelerator reference
      • getAccelerator

        public Accelerator getAccelerator()
        Returns the Accelerator associated with the represented action.
        Specified by:
        getAccelerator in interface ActionData
        Returns:
        the Accelerator
      • setAccelerator

        public void setAccelerator​(Accelerator accelerator)
        Allows setting an Accelerator for the represented action. This method may be called by tags in the body of this tag.
        Parameters:
        accelerator - the Accelerator for this action
      • checkAttributes

        protected void checkAttributes()
                                throws org.apache.commons.jelly.JellyTagException
        A helper method for checking whether all attributes are correctly defined. This implementation tests whether at least a text or an icon was provided for the action. Note that this method is not automatically called; sub classes must invoke it if necessary.
        Throws:
        org.apache.commons.jelly.JellyTagException - if attributes are invalid or required attributes are missing
      • processBeforeBody

        protected void processBeforeBody()
                                  throws org.apache.commons.jelly.JellyTagException,
                                         FormBuilderException
        Performs processing before the body of this tag gets executed. This implementation checks the accelerator specification. If one is defined, it is fetched and passed to the setAccelerator() method.
        Overrides:
        processBeforeBody in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if the tag is incorrectly used
        FormBuilderException - 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