Class ActionTag

  • All Implemented Interfaces:
    ActionData, ConditionalTag, IconSupport, org.apache.commons.jelly.Tag

    public class ActionTag
    extends AbstractActionDataTag

    A tag handler class for creating action objects.

    The purpose of this tag is to create a FormAction instance using the current ActionManager. All properties of the new action must be provided in attributes.

    After the action has been created, it is stored in the current ActionStore instance. From there it can be accessed by interested components. The following table lists all attributes supported by this tag (in addition the attributes defined in the base class can of course also be used):

    Attribute Description Optional
    taskBean Defines the name of the task for this action. It will be looked up in the current BeanContext (so it can be an arbitrary bean created by the dependency injection framework). If it does not exists, an exception will be thrown. depends
    taskBeanClass This attribute works similar to the task attribute, but the bean to be used for the task is specified by its class. The BeanContext will be asked for a bean of the specified class. depends
    taskcls With this attribute the action's task can be specified as a fully qualified class name. An instance of this class will be created (which must implement one of the supported interfaces) and passed to the action. Either one of the attributes taskBean, taskBeanClass, or taskClass must be provided. depends
    group Here the name of an action group can be specified, to which the action will be added. The ActionStore class provides support for groups of actions. If this attribute is specified, the current net.sf.jguiraffe.gui.builder.action.ActionStore ActionStore is told to add the action to the corresponding group. Refer to the ActionStore class for further information about action groups. yes
    enabled A boolean attribute which can be used to set the initial enabled state of the action. Per default, actions are enabled after they have been created. With this attribute, actions can be initially disabled. yes

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

      • ActionTag

        public ActionTag()
    • Method Detail

      • setTaskBean

        public void setTaskBean​(String name)
        Setter method for the taskBean attribute.
        Parameters:
        name - the attribute's value
      • setTaskBeanClass

        public void setTaskBeanClass​(Object c)
        Setter method for the taskBeanClass attribute.
        Parameters:
        c - the attribute's value
      • setTaskClass

        public void setTaskClass​(Object c)
        Setter method for the taskClass attribute.
        Parameters:
        c - the attribute value
      • getTask

        public Object getTask()
        Returns the task for the represented action.
        Returns:
        the task for this action
      • setTask

        public void setTask​(Object t)
        Allows to directly set the task for the represented action. This method can be used by sub tasks.
        Parameters:
        t - the task for this action
      • setGroup

        public void setGroup​(String s)
        Setter method for the group attribute.
        Parameters:
        s - the attribute value
      • isEnabled

        public boolean isEnabled()
        Returns the value of the enabled attribute.
        Returns:
        the attribute value
        Since:
        1.3.1
      • setEnabled

        public void setEnabled​(boolean enabled)
        Setter method for the enabled attribute.
        Parameters:
        enabled - the attribute value
        Since:
        1.3.1
      • process

        protected void process()
                        throws org.apache.commons.jelly.JellyTagException,
                               FormBuilderException
        Executes this task. Creates a new action object and stores it in the current action store.
        Specified by:
        process in class FormBaseTag
        Throws:
        org.apache.commons.jelly.JellyTagException - if attributes are incorrect
        FormBuilderException - if an error occurs creating the action
      • createTask

        protected Object createTask​(String taskName,
                                    Class<?> taskBeanClass,
                                    Class<?> taskClass)
                             throws org.apache.commons.jelly.JellyTagException,
                                    FormActionException
        Creates the task for this action. This task can be either defined by a reference to a bean, in which case it is looked up using the current bean context. Or it is defined through its class name, in which case a new instance of this class will be created. If the task bean is not yet available (because it is defined later in the builder script), a deferred task is created acting as a wrapper around the actual task which is initialized at the end of the builder operation.
        Parameters:
        taskName - the name of the task bean
        taskBeanClass - the class of the task bean
        taskClass - the task's class
        Returns:
        the new task
        Throws:
        org.apache.commons.jelly.JellyTagException - if attributes are invalid
        FormActionException - if an error occurs
      • createTaskByClass

        protected Object createTaskByClass​(Class<?> taskClass)
                                    throws FormActionException
        Creates the action's task if it is defined by its class.
        Parameters:
        taskClass - the class
        Returns:
        the task
        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