Class ElementTag
- java.lang.Object
-
- org.apache.commons.jelly.TagSupport
-
- net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
-
- net.sf.jguiraffe.gui.builder.di.tags.ElementTag
-
- All Implemented Interfaces:
ValueSupport
,org.apache.commons.jelly.Tag
public class ElementTag extends DependencyTag
A tag handler class that allows adding elements to collections.
Tags of this type can be placed in the body of a
tag. They define the elements to be added to the collection. An example usage could be as follows:CollectionTag
<list elementClassName="java.lang.Integer"> <element value="10"/> <element value="20"/> <element refName="intBean"/> ... </list>
ElementTag
is derived fromDependencyTag
and inherits all possibilities for defining the value (e.g. passing the value directly to thevalue
attribute, specifying the value class with support for automatic type conversions, defining the value as a complex object in the tag's body, declaring a dependency to another bean, etc.). The following table lists the supported attributes:Attribute Description Optional value With this attribute the value can be directly set. If the value is specified as a string constant and a value class is defined, an automatic type conversion will be performed. yes valueClass Here the class of the value can be specified. The tag will try to convert the value to this class if necessary. yes valueClassName This attribute has the same effect as valueClass
, but the name of the value class is specified rather than the class object itself.yes valueClassLoader If the name of the value class is specified, with this attribute a class loader for resolving the class can be defined. The name specified here will be passed to the current ClassLoaderProvider
for obtaining the desired class loader.yes refName With this attribute another bean can be referenced by its name. This bean will be resolved and become the value of this tag. yes refClass It is possible to refer to another bean by its class (for this purpose there should only be a single bean with this class so there are no ambiguities). The class of this bean can be specified by this attribute. yes refClassName This attribute has the same meaning as the refClass
attribute, but the class of the bean that is referenced can be specified by its name.yes refClassLoader If the refClassName
attribute is used for specifying the class of a bean referenced, with this attribute a class loader can be determined for resolving the class.yes It is also possible to define the tag's value using other tags that are placed in the body of this tag. Only a single way of defining the value must be used, otherwise an exception is thrown. If the value of this tag is undefined, a null dependency will be added to the collection, i.e. the corresponding element in the collection will be null.
- Version:
- $Id: ElementTag.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Constructor Summary
Constructors Constructor Description ElementTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Dependency
createValueDependency()
Creates the dependency when a constant value is specified for this tag.void
doTag(org.apache.commons.jelly.XMLOutput output)
Executes this tag.-
Methods inherited from class net.sf.jguiraffe.gui.builder.di.tags.DependencyTag
createDependency, getDependency, getRefClassData, getRefName, getValueData, getVar, hasDependency, processDependencyDefinitions, setDependency, setRefClass, setRefClassLoader, setRefClassName, setRefName, setValue, setValueClass, setValueClassLoader, setValueClassName, setVar
-
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
-
doTag
public void doTag(org.apache.commons.jelly.XMLOutput output) throws org.apache.commons.jelly.JellyTagException
Executes this tag. Checks whether the parent tag is a collection tag. If this is the case, the parent'saddElement()
method is called with the dependency specified for this tag.- Parameters:
output
- the output object- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs or the tag is incorrectly used
-
createValueDependency
protected Dependency createValueDependency() throws org.apache.commons.jelly.JellyTagException
Creates the dependency when a constant value is specified for this tag. This implementation obtains the class description of the elements specified at the collection level (if any). Then this description is used as fall back for a type conversion.- Overrides:
createValueDependency
in classDependencyTag
- Returns:
- the dependency for a (constant) value
- Throws:
org.apache.commons.jelly.JellyTagException
- if an error occurs
-
-