Tag Documentation

[tag libraries] [tags]

The following document contains a summary of all theJellytag 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
argAn 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.
breakA 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.
caseA 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.
catchA 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.
chooseA tag which conditionally evaluates its body based on some condition
defaultA 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.
exprA tag which evaluates an expression
fileA 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.
forEachIterates over a collection, iterator or an array of objects.Uses the same syntax as the JSTL forEach tag does.
getStaticA 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"/>
    
ifA tag which conditionally evaluates its body based on some condition
importImports 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.

includeA tag which conditionally evaluates its body based on some condition
invokeA tag which calls a method in an object instantied by core:new
invokeStaticA 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

jellyThe root Jelly tag which should be evaluated first
muteA 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.

newA tag which creates a new object of the given type
otherwiseThe otherwise block of a choose/when/otherwise group of tags
parseParses 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.
removeA tag which removes the variable of the given name from the current variable scope.
scopeA 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.
setA tag which sets a variable from the result of an expression
setPropertiesA 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.

switchExecutes the child <case>tag whose value equals my on attribute.Executes a child <default>tag when present and no <case>tag hasyet matched.
threadA tag that spawns the contained script in a separate thread
useBeanA 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"/>
    
useListA 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
whenA tag which conditionally evaluates its body based on some condition
whileA tag which performs an iteration while the result of an expression is true.
whitespaceA 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
classLoaderClassLoaderSet 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
typeStringThe 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.
valueObjectThe (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.
testExpressionSets 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
varStringSets 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
valueExpression

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
varStringSets 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
valueExpressionSets 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
appendbooleanSets wether to append at the end of the file(not really something you normally do with an XML file).
encodingStringSets 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.
nameStringSets the file name for the output
omitXmlDeclarationbooleanSets whether the XML declaration should be output or not
outputModeStringSets 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
varStringSets 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.
indexVarStringSets the variable name to export the current index counter to
itemsExpressionSets 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
varStringSets the variable name to export for the item being iterated over
varStatusStringSets the variable name to export the current status to.The status is an implementation of the JSTL LoopTagStatus interface that providesthe following bean properties:
  • current - the current value of the loop items being iterated
  • index - the current index of the items being iterated
  • first - true if this is the first iteration, false otherwise
  • last - true if this is the last iteration, false otherwise
  • begin - the starting index of the loop
  • step - the stepping value of the loop
  • end - the end index of the loop

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
classNameStringSets 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.
fieldStringSets 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
varStringSets 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.
testExpressionSets 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.
fileStringSets 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
uriStringSets 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.
exportString
fileFileSets the file to be included which is either an absolute file or a filerelative to the current directory
inheritString
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
uriStringSets 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.
exceptionVarStringSets the name of a variable that exports the exception thrown bythe method's invocation (if any)
methodString
onObject
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
varStringSets 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
classNameStringSets 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.
exceptionVarStringSets the name of a variable that exports the exception thrown bythe method's invocation (if any)
methodStringSets 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
varStringSets 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
classLoaderClassLoaderSet the class loader to be used for instantiating application objectswhen required.
classNameStringSets 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.
varStringSets 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
XMLReaderXMLReaderSets 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.
jellyParserXMLParserSets the jellyParser.
textStringSets 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
varStringSets 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
varExpressionSets 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
defaultValueExpressionSets 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.
propertyStringSets the name of the property to set on the target object.
scopeStringSets 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.
targetObjectSets 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
valueExpressionSets the expression to evaluate.
varStringSets 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.
onExpressionSets 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.
fileStringSet the file which is generated from the output
nameStringSets the name of the thread.
trimbooleanSets whether whitespace inside this tag should be trimmed or not.Defaults to true so whitespace is trimmed
xmlOutputXMLOutputSets 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.
testExpressionSets 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.
testExpressionSetter 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