Tag Documentation

[ tag libraries ] [ tags ]

The following document contains a summary of all the Jelly tag libraries.

Tag Libraries

[ tag libraries ] [ tags ]

LibraryDescription
jelly:core

The core Tags from the JSTL plus Jelly extensions.

jelly:core

The core Tags from the JSTL plus Jelly extensions.

Tag NameDescription
arg An argument to a org.apache.commons.jelly.tags.core.NewTagor org.apache.commons.jelly.tags.core.InvokeTag.This tag MUST be enclosed within an org.apache.commons.jelly.tags.core.ArgTagParentimplementation.
break A tag which terminates the execution of the current <forEach>or &lg;while>loop. This tag can take an optional boolean test attribute which if its truethen the break occurs otherwise the loop continues processing.
case A tag which conditionally evaluates its body ifmy valueattribute equals my ancestor <switch>tag's "on"attribute.This tag must be contained within the body of some <switch>tag.
catch A tag which catches exceptions thrown by its body.This allows conditional logic to be performed based on if exceptionsare thrown or to do some kind of custom exception logging logic.
choose A tag which conditionally evaluates its body based on some condition
default A tag which conditionally evaluates its body ifnone of its preceeding sibling <case>tags have been evaluated.This tag must be contained within the body of some <switch>tag.
expr A tag which evaluates an expression
file A tag that pipes its body to a file denoted by the name attribute or to an in memory Stringwhich is then output to a variable denoted by the var variable.
forEach Iterates over a collection, iterator or an array of objects.Uses the same syntax as the JSTL forEach tag does.
getStatic A tag which can retrieve the value of a static field of a given class.The following attributes are required:

  • var - The variable to which to assign the resulting value.
  • field - The name of the static field to retrieve.
  • className - The name of the class containing the static field.
Example usage:
       <j:getStatic var="closeOperation" className="javax.swing.JFrame"field="EXIT_ON_CLOSE"/>
    
if A tag which conditionally evaluates its body based on some condition
import Imports another script.

By default, the imported script does not have access tothe parent script's variable context. This behaviourmay be modified using the inherit attribute.

include A tag which conditionally evaluates its body based on some condition
invoke A tag which calls a method in an object instantied by core:new
invokeStatic A Tag which can invoke a static method on a class, without aninstance of the class being needed.

Like the

org.apache.commons.jelly.tags.core.InvokeTag, this tag can take a set ofarguments using the org.apache.commons.jelly.tags.core.ArgTag.

The following attributes are required:

  • var - The variable to assign the return of the method call to
  • method - The name of the static method to invoke
  • className - The name of the class containing the static method

jelly The root Jelly tag which should be evaluated first
mute A tag which executes its body but passing no output.

Using this tag will still take the time to perform toString on each objectreturned to the output (but this toString value is discarded.A future version should go more internally so that this is avoided.

new A tag which creates a new object of the given type
otherwise The otherwise block of a choose/when/otherwise group of tags
parse Parses the output of this tags body or of a given String as a Jelly scriptthen either outputting the Script as a variable or executing the script.
remove A tag which removes the variable of the given name from the current variable scope.
scope A tag which creates a new child variable scope for its body.So any variables defined within its body will no longer be in scopeafter this tag.
set A tag which sets a variable from the result of an expression
setProperties A tag which sets the bean properties on the given bean.So if you used it as follows, for example using the <j:new>tag.
       <j:new className="com.acme.Person" var="person"/> <j:setProperties object="${person}" name="James" location="${loc}"/>
    
Then it would set the name and location properties on the bean denoted bythe expression ${person}.

This tag can also be nested inside a bean tag such as the <useBean>tagor a JellySwing tag to set one or more properties, maybe inside some conditionallogic.

switch Executes the child <case>tag whose value equals my on attribute.Executes a child <default>tag when present and no <case>tag hasyet matched.
thread A tag that spawns the contained script in a separate thread
useBean A tag which instantiates an instance of the given classand then sets the properties on the bean.The class can be specified via a java.lang.Classinstance ora String which will be used to load the class using either the currentthread's context class loader or the class loader used to load thisJelly library.This tag can be used it as follows,
       <j:useBean var="person" class="com.acme.Person" name="James" location="${loc}"/> <j:useBean var="order" class="${orderClass}" amount="12" price="123.456"/>
    
useList A tag which creates a List implementation and optionallyadds all of the elements identified by the items attribute.The exact implementation of List can be specified via theclass attribute
when A tag which conditionally evaluates its body based on some condition
while A tag which performs an iteration while the result of an expression is true.
whitespace A simple tag used to preserve whitespace inside its body

Tags

[ tag libraries ] [ tags ]

core:arg

An argument to a org.apache.commons.jelly.tags.core.NewTagor org.apache.commons.jelly.tags.core.InvokeTag.This tag MUST be enclosed within an org.apache.commons.jelly.tags.core.ArgTagParentimplementation.

Attribute NameTypeDescription
classLoaderjava.lang.ClassLoaderSet the class loader to be used for instantiating application objectswhen required.
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
typejava.lang.StringThe name of the argument class or type, if any.This may be a fully specified class name ora primitive type name( boolean , int , double , etc.).
useContextClassLoaderbooleanDetermine whether to use the Context ClassLoader (the one found bycalling Thread.currentThread().getContextClassLoader() )to resolve/load classes. If notusing Context ClassLoader, then the class-loading defaults tousing the calling-class' ClassLoader.
valuejava.lang.ObjectThe (possibly null) value of this argument.

core:break

A tag which terminates the execution of the current <forEach>or &lg;while>loop. This tag can take an optional boolean test attribute which if its truethen the break occurs otherwise the loop continues processing.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
testorg.apache.commons.jelly.expression.ExpressionSets the Jelly expression to evaluate (optional).If this is null or evaluates to true then the loop is terminated
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the variable name to export indicating if the item was broken

core:case

A tag which conditionally evaluates its body ifmy valueattribute equals my ancestor <switch>tag's "on"attribute.This tag must be contained within the body of some <switch>tag.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
fallThruboolean
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
valueorg.apache.commons.jelly.expression.Expression

core:catch

A tag which catches exceptions thrown by its body.This allows conditional logic to be performed based on if exceptionsare thrown or to do some kind of custom exception logging logic.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the name of the variable which is exposed with the Exception that getsthrown by evaluating the body of this tag or which is set to null if there isno exception thrown.

core:choose

A tag which conditionally evaluates its body based on some condition

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:default

A tag which conditionally evaluates its body ifnone of its preceeding sibling <case>tags have been evaluated.This tag must be contained within the body of some <switch>tag.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
fallThruboolean
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:expr

A tag which evaluates an expression

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
valueorg.apache.commons.jelly.expression.ExpressionSets the Jexl expression to evaluate.

core:file

A tag that pipes its body to a file denoted by the name attribute or to an in memory Stringwhich is then output to a variable denoted by the var variable.

Attribute NameTypeDescription
encodingjava.lang.StringSets the XML encoding mode, which defaults to UTF-8
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
namejava.lang.StringSets the file name for the output
omitXmlDeclarationbooleanSets whether the XML declaration should be output or not
outputModejava.lang.StringSets the output mode, whether XML or HTML
prettyPrintbooleanSets whether pretty printing mode is turned on. The default is off so that whitespace is preserved
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the var.

core:forEach

Iterates over a collection, iterator or an array of objects.Uses the same syntax as the JSTL forEach tag does.

Attribute NameTypeDescription
beginintSets the starting index value
endintSets the ending index value
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
indexVarjava.lang.StringSets the variable name to export the current index counter to
itemsorg.apache.commons.jelly.expression.ExpressionSets the expression used to iterate over.This expression could resolve to an Iterator, Collection, Map, Array,Enumeration or comma separated String.
stepintSets the index increment step
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the variable name to export for the item being iterated over
varStatusjava.lang.StringSets the variable name to export the current index to.This does the same thing as #setIndexVar(), but is consistentwith the JSTL syntax.

core:getStatic

A tag which can retrieve the value of a static field of a given class.The following attributes are required:

  • var - The variable to which to assign the resulting value.
  • field - The name of the static field to retrieve.
  • className - The name of the class containing the static field.
Example usage:
       <j:getStatic var="closeOperation" className="javax.swing.JFrame"field="EXIT_ON_CLOSE"/>
    

Attribute NameTypeDescription
classNamejava.lang.StringSets the fully qualified name of the class containing the static field.
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
fieldjava.lang.StringSets the name of the field to retrieve.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the name of the variable exported by this tag.

core:if

A tag which conditionally evaluates its body based on some condition

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
testorg.apache.commons.jelly.expression.ExpressionSets the Jelly expression to evaluate. If this returns true, the body ofthe tag is evaluated
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:import

Imports another script.

By default, the imported script does not have access tothe parent script's variable context. This behaviourmay be modified using the inherit attribute.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
filejava.lang.StringSets the file for the script to evaluate.
inheritbooleanSets whether property inheritence is enabled or disabled
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
urijava.lang.StringSets the URI (relative URI or absolute URL) for the script to evaluate.

core:include

A tag which conditionally evaluates its body based on some condition

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
exportjava.lang.String
filejava.io.FileSets the file to be included which is either an absolute file or a filerelative to the current directory
inheritjava.lang.String
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
urijava.lang.StringSets the URI (relative URI or absolute URL) for the script to evaluate.

core:invoke

A tag which calls a method in an object instantied by core:new

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
exceptionVarjava.lang.StringSets the name of a variable that exports the exception thrown bythe method's invocation (if any)
methodjava.lang.String
onjava.lang.Object
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the name of the variable exported by this tag

core:invokeStatic

A Tag which can invoke a static method on a class, without aninstance of the class being needed.

Like the

org.apache.commons.jelly.tags.core.InvokeTag, this tag can take a set ofarguments using the org.apache.commons.jelly.tags.core.ArgTag.

The following attributes are required:

  • var - The variable to assign the return of the method call to
  • method - The name of the static method to invoke
  • className - The name of the class containing the static method

Attribute NameTypeDescription
classNamejava.lang.StringSets the fully qualified class name containing the static method
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
exceptionVarjava.lang.StringSets the name of a variable that exports the exception thrown bythe method's invocation (if any)
methodjava.lang.StringSets the name of the method to invoke
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the name of the variable exported by this tag

core:jelly

The root Jelly tag which should be evaluated first

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:mute

A tag which executes its body but passing no output.

Using this tag will still take the time to perform toString on each objectreturned to the output (but this toString value is discarded.A future version should go more internally so that this is avoided.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:new

A tag which creates a new object of the given type

Attribute NameTypeDescription
classLoaderjava.lang.ClassLoaderSet the class loader to be used for instantiating application objectswhen required.
classNamejava.lang.StringSets the class name of the object to instantiate
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
useContextClassLoaderbooleanDetermine whether to use the Context ClassLoader (the one found bycalling Thread.currentThread().getContextClassLoader() )to resolve/load classes. If notusing Context ClassLoader, then the class-loading defaults tousing the calling-class' ClassLoader.
varjava.lang.StringSets the name of the variable exported by this tag

core:otherwise

The otherwise block of a choose/when/otherwise group of tags

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:parse

Parses the output of this tags body or of a given String as a Jelly scriptthen either outputting the Script as a variable or executing the script.

Attribute NameTypeDescription
XMLReaderorg.xml.sax.XMLReaderSets the XMLReader used for parsing
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
jellyParserorg.apache.commons.jelly.parser.XMLParserSets the jellyParser.
textjava.lang.StringSets the text to be parsed by this parser
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varjava.lang.StringSets the variable name that will be used for the Document variable created

core:remove

A tag which removes the variable of the given name from the current variable scope.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varorg.apache.commons.jelly.expression.ExpressionSets the name of the variable which will be removed by this tag..

core:scope

A tag which creates a new child variable scope for its body.So any variables defined within its body will no longer be in scopeafter this tag.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:set

A tag which sets a variable from the result of an expression

Attribute NameTypeDescription
defaultValueorg.apache.commons.jelly.expression.ExpressionSets the default value to be used if the value exprsesion resultsin a null value or blank String
encodebooleanSets whether the body of the tag should be XML encoded as text (so that <and >areencoded as &lt; and &gt;) or leave the text as XML which is the default.This is only used if this tag is specified with no value so that the text body of thistag is used as the body.
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
propertyjava.lang.StringSets the name of the property to set on the target object.
scopejava.lang.StringSets the variable scope for this variable. For example setting this value to 'parent' willset this value in the parent scope. When Jelly is run from inside a Servlet environmentthen other scopes will be available such as 'request', 'session' or 'application'.Other applications may implement their own custom scopes.
targetjava.lang.ObjectSets the target object on which to set a property.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
valueorg.apache.commons.jelly.expression.ExpressionSets the expression to evaluate.
varjava.lang.StringSets the variable name to define for this expression

core:setProperties

A tag which sets the bean properties on the given bean.So if you used it as follows, for example using the <j:new>tag.

       <j:new className="com.acme.Person" var="person"/> <j:setProperties object="${person}" name="James" location="${loc}"/>
    
Then it would set the name and location properties on the bean denoted bythe expression ${person}.

This tag can also be nested inside a bean tag such as the <useBean>tagor a JellySwing tag to set one or more properties, maybe inside some conditionallogic.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:switch

Executes the child <case>tag whose value equals my on attribute.Executes a child <default>tag when present and no <case>tag hasyet matched.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
onorg.apache.commons.jelly.expression.ExpressionSets the value to switch on.Note that the org.apache.commons.jelly.expression.Expressionis evaluated only once, when the <switch>tag is evaluated.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:thread

A tag that spawns the contained script in a separate thread

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
filejava.lang.StringSet the file which is generated from the output
namejava.lang.StringSets the name of the thread.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
xmlOutputorg.apache.commons.jelly.XMLOutputSets the destination of output

core:useBean

A tag which instantiates an instance of the given classand then sets the properties on the bean.The class can be specified via a java.lang.Classinstance ora String which will be used to load the class using either the currentthread's context class loader or the class loader used to load thisJelly library.This tag can be used it as follows,

       <j:useBean var="person" class="com.acme.Person" name="James" location="${loc}"/> <j:useBean var="order" class="${orderClass}" amount="12" price="123.456"/>
    

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
ignoreUnknownPropertiesbooleanIf this tag finds an attribute in the XML that's notignored by org.apache.commons.jelly.tags.core.UseBeanTag.ignorePropertiesand isn't abean property, should it throw an exception?
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:useList

A tag which creates a List implementation and optionallyadds all of the elements identified by the items attribute.The exact implementation of List can be specified via theclass attribute

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
ignoreUnknownPropertiesbooleanIf this tag finds an attribute in the XML that's notignored by org.apache.commons.jelly.tags.core.UseBeanTag.ignorePropertiesand isn't abean property, should it throw an exception?
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:when

A tag which conditionally evaluates its body based on some condition

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
testorg.apache.commons.jelly.expression.ExpressionSets the expression to evaluate.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:while

A tag which performs an iteration while the result of an expression is true.

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
testorg.apache.commons.jelly.expression.ExpressionSetter for the expression
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed

core:whitespace

A simple tag used to preserve whitespace inside its body

Attribute NameTypeDescription
escapeTextbooleanSets whether the body of the tag should be escaped as text (so that <and >areescaped as &lt; and &gt;), which is the default or leave the text as XML.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed