Class ActionTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
-
- net.sf.jguiraffe.gui.builder.action.tags.AbstractActionDataTag
-
- net.sf.jguiraffe.gui.builder.action.tags.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 currentActionManager
. 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. TheBeanContext
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
, ortaskClass
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 currentnet.sf.jguiraffe.gui.builder.action.ActionStore ActionStore
is told to add the action to the corresponding group. Refer to theActionStore
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 Summary
Constructors Constructor Description ActionTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
createTask(String taskName, Class<?> taskBeanClass, Class<?> taskClass)
Creates the task for this action.protected Object
createTaskByClass(Class<?> taskClass)
Creates the action's task if it is defined by its class.protected ActionBuilder
getActionBuilder()
Returns a reference to the currentActionBuilder
instance.protected ActionManager
getActionManager()
Convenience method for obtaining a reference to the currentActionManager
.Object
getTask()
Returns the task for the represented action.boolean
isEnabled()
Returns the value of the enabled attribute.protected void
process()
Executes this task.void
setEnabled(boolean enabled)
Setter method for the enabled attribute.void
setGroup(String s)
Setter method for the group attribute.void
setTask(Object t)
Allows to directly set the task for the represented action.void
setTaskBean(String name)
Setter method for the taskBean attribute.void
setTaskBeanClass(Object c)
Setter method for the taskBeanClass attribute.void
setTaskClass(Object c)
Setter method for the taskClass attribute.-
Methods inherited from class net.sf.jguiraffe.gui.builder.action.tags.AbstractActionDataTag
checkAttributes, getAccelerator, getAcceleratorDef, getAcceleratorRef, getIcon, getMnemonicKey, getName, getText, getToolTip, processBeforeBody, setAccelerator, setAcceleratorDef, setAcceleratorRef, setIcon, setMnemonic, setMnemonicres, setName, setResgrp, setText, setTextres, setTooltip, setTooltipres
-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.FormBaseTag
canProcess, canProcess, convertToClass, convertToNumberWithUnit, convertToNumberWithUnit, doTag, findContainer, getBuilderData, getBuilderData, getIfName, getResourceText, getResourceText, getUnlessName, setIfName, setUnlessName
-
Methods inherited from class org.apache.commons.jelly.TagSupport
findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, findAncestorWithClass, getBody, getBodyText, getBodyText, getContext, getParent, invokeBody, isEscapeText, isTrim, setBody, setContext, setEscapeText, setParent, setTrim, trimBody
-
-
-
-
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 classFormBaseTag
- Throws:
org.apache.commons.jelly.JellyTagException
- if attributes are incorrectFormBuilderException
- 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 beantaskBeanClass
- the class of the task beantaskClass
- the task's class- Returns:
- the new task
- Throws:
org.apache.commons.jelly.JellyTagException
- if attributes are invalidFormActionException
- 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 currentActionBuilder
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 currentActionManager
.- Returns:
- the current action manager
-
-