Class TransformerBaseTag<T>
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- org.apache.commons.jelly.DynaTagSupport
-
- org.apache.commons.jelly.MapTagSupport
-
- org.apache.commons.jelly.tags.core.UseBeanTag
-
- net.sf.jguiraffe.gui.builder.components.tags.UseBeanBaseTag
-
- net.sf.jguiraffe.gui.builder.components.tags.TransformerBaseTag<T>
-
- Type Parameters:
T
- the type of service object created by this tag
- All Implemented Interfaces:
ConditionalTag
,PropertiesSupport
,PropertySupport
,org.apache.commons.jelly.DynaTag
,org.apache.commons.jelly.impl.BeanSource
,org.apache.commons.jelly.Tag
- Direct Known Subclasses:
TransformerTag
,ValidatorBaseTag
public abstract class TransformerBaseTag<T> extends UseBeanBaseTag implements PropertiesSupport
A base class for tags that create transformers or validators.
This class provides common functionality for creating service objects for field handlers. It determines the
InputComponentTag
this tag is nested inside and prepares the passing of the newly created transformer or validator. Concrete sub classes only have to call the correct set method on the input component tag.The transformer or validator itself is created using the functionality provided by the ancestor
UseBeanTag
. This results in a reference to a bean. For this bean properties can be defined by tags specified in the body of this tag. When the bean is invoked these properties are then taken into account.- Version:
- $Id: TransformerBaseTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Field Summary
-
Fields inherited from class net.sf.jguiraffe.gui.builder.components.tags.UseBeanBaseTag
ATTR_BEAN_CLASS, ATTR_BEAN_NAME, ATTR_CLASS, ATTR_IF_NAME, ATTR_REF, ATTR_UNLESS_NAME, ATTR_VAR
-
-
Constructor Summary
Constructors Constructor Description TransformerBaseTag()
Creates a new instance ofTransformerBaseTag
.TransformerBaseTag(Class<?> defClass)
Creates a new instance ofTransformerBaseTag
and sets the default class.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
getProperties()
Returns properties for the created bean.protected TransformerContext
getTransformerContext()
Returns aTransformerContext
for the managed bean.protected abstract void
handleInputComponentTag(InputComponentTag tag, T bean)
Passes the bean to the givenInputComponentTag
.protected boolean
handleOtherParent(org.apache.commons.jelly.Tag parent, T bean)
Processes the parent tag.protected boolean
passResults(Object bean)
Passes the bean to its target.void
setProperties(Map<String,Object> properties)
Sets properties for the created bean.-
Methods inherited from class net.sf.jguiraffe.gui.builder.components.tags.UseBeanBaseTag
addIgnoreProperties, doTag, fetchBean, getAdditionalProperties, getAttributeStr, getBaseClass, getIfName, getUnlessName, isOptional, processBean, setBaseClass, setProperty, useExistingBean
-
Methods inherited from class org.apache.commons.jelly.tags.core.UseBeanTag
addIgnoreProperty, convertToClass, getBean, getDefaultClass, getIgnorePropertySet, isIgnoreUnknownProperties, loadClass, newInstance, setBean, setBeanProperties, setIgnoreUnknownProperties, validateBeanProperties
-
Methods inherited from class org.apache.commons.jelly.MapTagSupport
createAttributes, getAttributes, setAttribute
-
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
-
-
-
-
Constructor Detail
-
TransformerBaseTag
public TransformerBaseTag()
Creates a new instance ofTransformerBaseTag
.
-
TransformerBaseTag
public TransformerBaseTag(Class<?> defClass)
Creates a new instance ofTransformerBaseTag
and sets the default class.- Parameters:
defClass
- the default class
-
-
Method Detail
-
getProperties
public Map<String,Object> getProperties()
Returns properties for the created bean.- Returns:
- properties
-
setProperties
public void setProperties(Map<String,Object> properties)
Sets properties for the created bean. It is possible to define properties for a specific transformer or validator. These properties are stored and are available through theTransformerContext
interface. Using this mechanism it is possible to customize the behavior of a transformer or validator for a specific invocation.- Specified by:
setProperties
in interfacePropertiesSupport
- Parameters:
properties
- the properties for the current bean
-
getTransformerContext
protected TransformerContext getTransformerContext()
Returns aTransformerContext
for the managed bean. If no properties have been set, the global context is returned. Otherwise a wrapped context is created that takes the properties into account.- Returns:
- a
TransformerContext
to be used for the managed bean
-
handleOtherParent
protected boolean handleOtherParent(org.apache.commons.jelly.Tag parent, T bean) throws org.apache.commons.jelly.JellyTagException
Processes the parent tag. This method is called if the parent of this tag is noInputComponentTag
. This base implementation will simply return false in this case (because per default only input component tags are supported as parents). If a derived class supports other parent tags, this method can be overridden.- Parameters:
parent
- the parent tagbean
- the bean created by this tag- Returns:
- a flag whether the parent tag is supported
- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs
-
passResults
protected boolean passResults(Object bean) throws org.apache.commons.jelly.JellyTagException
Passes the bean to its target. This implementation checks whether the parent of this tag is anInputComponentTag
. If yes,handleInputComponentTag()
will be called. OtherwisehandleOtherParent()
is invoked.- Overrides:
passResults
in classUseBeanBaseTag
- Parameters:
bean
- the affected bean- Returns:
- a flag whether the bean could be passed to a target
- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs
-
handleInputComponentTag
protected abstract void handleInputComponentTag(InputComponentTag tag, T bean) throws org.apache.commons.jelly.JellyTagException
Passes the bean to the givenInputComponentTag
. This method is called when this tag is placed inside the body of anInputComponentTag
. Derived classes can here perform the necessary steps to initialize the input component tag.- Parameters:
tag
- the input component tagbean
- the bean- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs
-
-