Return-Path:
You will find here a summary of all the available standard tools, sufficient for a basic
+ integration and usage of each of them. Please refer to the javadoc for a complete reference of all their methods and properties, since only an excerpt is show here.
+ AlternatorTool,
+ ClassTool,
+ ComparisonDateTool,
+ ContextTool,
+ ConversionTool,
+ DisplayTool,
+ EscapeTool,
+ FieldTool,
+ LinkTool,
+ MathTool,
+ NumberTool,
+ RenderTool,
+ ResourceTool,
+ SortTool,
+ XmlTool
+
+ AbstractSearchTool,
+ BrowserTool,
+ CookieTool,
+ ImportTool,
+ IncludeTool,
+ LinkTool,
+ PagerTool,
+ ParameterTool,
+ ViewContextTool
+
+ ActionMessagesTool,
+ ErrorsTool,
+ FormTool,
+ MessageResourcesTool,
+ SecureLinkTool,
+ StrutsLinkTool,
+ TilesTool,
+ ValidatorTool
+
+ Generic Tools
+ View Tools
+ Struts Tools
+
+
+
+
+ AlternatorTool
+ tool to create alternators (variables that cycle through an array)
+
+
+ default key
+ $alternator
+
+ configuration properties
+ autoAlternate
+ boolean, states whether the alternator will automatically switch values at each rendering (defaults to
+ true
)
+
+ methods and properties
+
+ $autoAlternateDefault
returns
+ true
if alternators created by this tool will auto-alternate by default, or set the property to a new boolean value
+
+
+ #set( $alt = $alternator.auto(value1,value2,...) )
creates an automatic alternator
+
+
+
+ #set( $alt = $alternator.make(value1,value2,...) )
creates an alternator with default auto behaviour
+
+
+
+ #set( $alt = $alternator.manual(value1,value2,...) )
creates a manual alternator
+
+
+ Alternator
+ alternator object created by means of an AlternatorTool
+
+
+ methods and properties
+
+ $alt
displays current value (and shift for automatic alternators)
+
+
+
+ $alt.current
displays current value
+
+
+
+ $alt.next
displays current value and shift
+
+
+
+ $alt.shift
shifts to next value
+
+
+
+ $alt.auto
read/write property stating if this is an automatic alternator
+
+
+ ClassTool
+ tool meant to use Java reflection in templates
+
+
+ default key
+ $class
+
+ configuration properties
+ inspect
+ string, class name of the class which is to be inspected (defaults to
+ java.lang.Object
)
+
+ safeMode
+ boolean, indicates whether to only show public members, fields and constructors (defaults to
+ true
)
+
+ showDeprecated
+ boolean, states whether deprecated members, fields and constructors are to be shown (defaults to
+ false
)
+
+ methods and properties
+
+ $class.annotations
returns a list of the
+ Annotations
of the class being inspected
+
+
+ $class.constructors
returns a list of
+ ConstructorSub
s for each constructor declared in the inspected class, with the following methods and read-only properties: $ctor.name
, $ctor.parameters
(array of Class
), $ctor.isVarArgs()
, $ctor.modifiers
(some were omitted)
+
+
+ $class.field
returns a list of
+ FieldSub
s for each field declared in the inspected class, with the following read-only properties: $field.name
, $field.modifiers
, $field.staticValue
, $field.type
(some were omitted)
+
+
+ $class.fullName
full name of the inspected cass
+
+
+
+ $class.methods
returns a list of
+ MethodSub
s for each method declared in the inspected class, with the following methods and read-only properties: $method.name
, $method.parameters
(array of Class
), $method.returns
, $method.isVarArgs()
, $method.modifiers
, $method.propertyName
(If this method can be treated as a bean property in Velocity, then it will return the "bean property" equivalent of the method name), $method.isVoid()
(some were omitted)
+
+
+ $class.name
returns the simple name of the class being inspected
+
+
+
+ $class.package
returns the package name of the class being inspected
+
+
+
+ $class.showDeprecated
returns or sets the current showDeprecated setting
+
+
+
+ $class.super
returns a new ClassTool instance that inspects the immediate superclass of the class being inspected
+
+
+
+ $class.type
returns the actual Class being inspected
+
+
+
+ $class.inspect(class/object/string)
returns a new ClassTool instance that inspects the specified class or object
+
+
+
+ $class.abstract
returns true if the class being inspected is abstract
+
+
+
+ $class.deprecated
returns true if the class being inspected is deprecated
+
+
+
+ $class.final
returns true if the class being inspected is final
+
+
+
+ $class.interface
returns true if the class being inspected is an interface
+
+
+
+ $class.supportsNewInstance()
returns true if a new instance of the class being inspected can be created via
+ $class.type.newInstance()
+
+ ComparisonDateTool
+ tool used to format, parse and compare dates
+
+
+ default key
+
+ $date
+
+ configuration properties
+ format
+ default format (see formatting pattens)
+
+
+ locale
+ default locale
+
+
+
+ timezone
+ time zone
+
+
+ methods and properties
+
+ $date
returns the current date and time formatted with the default format
+
+
+
+ $date.format( [ format, ] object [ , locale [ , timezone ] ] )
formats the specified object
+
+
+
+ $date.get( format )
returns the current date and time formatted using hte given format
+
+
+
+ $date.get( date style, time style )
returns the current date and time formatted using given styles, where each style is one of
+ full
, long
, medium
, short
, default
+
+
+ $date.day
current day in month
+
+
+
+ $date.month
current month (warning: zero-based!)
+
+
+
+ $date.year
current year
+
+
+
+ $date.getDay( object )
day of month of given date
+
+
+
+ $date.getMonth( object )
month of given date (warning: zero-based!)
+
+
+
+ $date.getYear( object )
year of given date
+
+
+
+ $date.format
returns or sets the pattern or style to be used for formatting dates when none is specified
+
+
+
+ $date.locale
returns or sets the default Locale configured for this instance
+
+
+
+ $date.timeZone
returns or sets the default TimeZone configured for this instance -
+ $date.timeZone.ID
displays the ID of the currently active TimeZone
+
+
+ $date.systemDate
gets the Date at the time this page was rendered for the system running this application
+
+
+
+ $date.toCalendar( object )
converts the given object to a java.util.Calendar
+
+
+
+ $date.toDate( object )
convers the given object to a java.util.Date
+
+
+
+ $date.whenIs( object )
returns a
+ ComparisonDateTool.Comparison
between current and specified date ; returned comparison will have properties like: $comp.years
, $comp.months
, $comp.weeks
, $comp.days
, $comp.hours
, $comp.minutes
, $comp.seconds
, $comp.milliseconds
, along with several other formatting methods
+
+
+ $date.whenIs( object, object )
returns a
+ ComparisonDateTool.Comparison
between the two specified dates ; returned comparison will have properties like: $comp.years
, $comp.months
, $comp.weeks
, $comp.days
, $comp.hours
, $comp.minutes
, $comp.seconds
, $comp.milliseconds
, along with several other formatting methods
+
+ ContextTool
+ tool allowing Velocity context introspection
+
+
+ default key
+
+ $context
+
+ methods and properties
+
+ $context.contains( key )
returns true if the context contains a non-null value for the specified key
+
+
+
+ $context.keys
returns a
+ java.util.Set
of the keys available in the current request context
+
+
+ $context.this
returns the ViewContext currently being analyzed by this tool
+
+
+
+ $context.toolbox
returns a
+ java.util.Map
of all the tools available in the current request context and their context keys
+
+
+ $context.values
returns a
+ java.util.Set
of the values available in the current request context
+
+
+ $context.get( key )
returns the value for the specified key in the current request context
+
+
+ ConversionTool
+ tool allowing conversions between datatypes
+
+
+ default key
+
+ $convert
+
+ configuration properties
+ stringsDelimiter
+ delimiter used when parsing concatenated strings arrays (defaults to ',')
+
+
+ trimStrings
+ boolean, states whether or not trim strings when parsing concatenated strings arrays (defaults to
+ true
)
+
+ numberFormat
+ number format to use when parsing numbers
+
+
+ dateFormat
+ date format to use when parsing dates
+
+
+ methods and properties
+
+ $convert.stringsDelimiter
delimiter used when parsing concatenated strings arrays
+
+
+
+ $convert.stringsTrim
whether or not strings are trimmed when parsing concatenated strings arrays
+
+
+
+ $convert.dateFormat
current date format used when parsing dates
+
+
+
+ $convert.numberFormat
current number format used when parsing numbers
+
+
+
+ $convert.parseDate( string [ , format [ , locale [ , timezone ] ] ] )
parses a date
+
+
+
+ $convert.parseNumber( string [ , format [ , locale ] ] )
parses a number
+
+
+
+ $convert.toType( object )
converts an object to an instance of
+ Type
, where Type
can be one of Boolean
, Calendar
, Date
, Double
, Integer
, Locale
, Number
, String
+
+
+ $convert.toTypes( object )
converts an array, Collection, delimited String, or object to an array of
+ Type
s, where Type
can be one of Boolean
, Calendar
, Date
, Double
, Integer
, Locale
, Number
, String
+
+ DisplayTool
+ tool providing a variety of methods for controlling the output displayed by various references in your templates
+
+
+ default key
+
+ $display
+
+ configuration properties
+ listDelim
+ default delimiter used between items by the list formatting methods (defaults to ',')
+
+
+ listFinalDelim
+ default delimiter used between the last two items by the list formatting methods (defaults to ' and ')
+
+
+ truncateLength
+ default length used by truncate(Object) (defaults to 30)
+
+
+ truncateSuffix>
+ default suffix used by the truncate methods (defaults to '...')
+
+
+ truncateAtWord
+ boolean, whether to truncate at a precise character or the last fitting word (defaults to
+ false
+
+ cellLength
+ cell size
+
+
+ cellSuffix
+ suffix used when cell contents need truncating
+
+
+ defaultAlternate
+ alternate used by alt(Object) (defaults to 'null')
+
+
+ allowedTags
+ tags allowed to remain by stripTags(Object) (none by defaults)
+
+
+ locale
+ used locale
+
+
+ methods and properties
+
+ $display.listDelimiter
returns or sets the configured default delimiter used between items by the list formatting methods
+
+
+
+ $display.listFinalDelimiter
returns or sets the configured default delimiter used between the last two items by the list formatting methods
+
+
+
+ $display.truncateLength
returns or sets the configured default length used by truncate(Object)
+
+
+
+ $display.truncateSuffix
returns or sets the default suffix used by the truncate methods
+
+
+
+ $display.truncateAtWord
returns or sets whether or not to truncate at a precise character or the last fitting word
+
+
+
+ $display.cellLength
returns or sets configured cell length
+
+
+
+ $display.cellSuffix
returns or sets the suffix used when cell contents need truncating
+
+
+
+ $display.defaultAlternate
returns or sets the configured default alternate used by alt(Object)
+
+
+
+ $display.allowedTags
returns or sets the configured tags allowed to remain by stripTags(Object)
+
+
+
+ $display.alt( object [ , object ] )
returns the configured default value (or the second argument if specified) if the specified first value is null
+
+
+
+ $display.br( object )
inserts HTML line break tag (
+
) in front of all newline characters of the string value of the specified object and returns the resulting string
+
+
+ $display.capitalize( object )
changes the first character of the string value of the specified object to upper case and returns the resulting string
+
+
+
+ $display( object [ , suffix ] [ , length ]
truncates or pads the string value of the specified object as necessary to ensure that the returned string's length equals the default or specified cell size, using the default suffix or the specified one when truncation is needed
+
+
+
+ $display.list( object [ , delim [ , finalDelim ] ] )
Formats a collection or array into a string, using the default or provided delimiter and final delimiter
+
+
+
+ $display.measure( object )
returns the measurements of the string value of the specified object
+
+
+
+ $display.message( string, object...)
uses
+ java.text.MessageFormat
to format the specified string with the specified arguments. If there are no arguments, then the string is returned directly
+
+
+ $display.plural( count, singular [ , plural ] )
based on count, returns singular or build/specified plural
+
+
+
+ $display.printf( format, object... )
uses
+ String.format(Locale,String,Object...)
to format the specified String with the specified arguments. Please note that the format required here is quite different from that of message(String,Object...)
+
+
+ $display.space( int )
returns a string of spaces of the specified length
+
+
+
+ $display.stripTags( object [ , allowedTags ] )
removes all not allowed HTML tags from the string value of the specified object and returns the resulting string
+
+
+
+ $display.truncate( object [ , size ] [ , suffix ] )
limits the string output of the first argument to the specified or default number of characters. If the string gets curtailed, the specified or default suffix is used as the ending of the truncated string
+
+
+
+ $display.uncapitalize( object )
changes the first character of the string value of the specified object to lower case and returns the resulting string
+
+
+ EscapeTool
+ tool providing some escaping facilities
+
+
+ default key
+
+ $esc
+
+ methods and properties
+
+ $esc.b
, $esc.backslash
renders a backslash (\)
+
+
+
+ $esc.d
, $esc.dollar
renders a dollar sign ($)
+
+
+
+ $esc.e
, $esc.exclamation
renders an exclamation mark (!)
+
+
+
+ $esc.h
, $esc.hash
renders a hash (#)
+
+
+
+ $esc.q
, $esc.quote
renders a double quotation mark (")
+
+
+
+ $esc.s
, $esc.singleQuote
renders a single quotation mark (')
+
+
+
+ $esc.html( string )
escapes the characters in a string using HTML entities
+
+
+
+ $esc.url( string )
escapes the characters in a string using UTF-8 URL character encoding
+
+
+
+ $esc.java( string )
escapes the characters in a String using Java String rules
+
+
+
+ $esc.javascript( string )
escapes the characters in a String using JavaScript String rules
+
+
+
+ $esc.sql( string )
escapes the characters in a String to be suitable to pass to an SQL query
+
+
+
+ $esc.xml( string )
escapes the characters in a String using XML entities
+
+
+
+ $esc.propertyKey( string )
escapes the characters in a String using java.util.Properties rules for escaping keys
+
+
+
+ $esc.propertyValue( string )
escapes the characters in a String using java.util.Properties rules for escaping values
+
+
+ FieldTool
+ tool allowing easy access to public static fields in classes, such as string constants
+
+
+ default key
+
+ $field
+
+ methods and properties
+
+ $field.get( string )
returns the value of the field with the specified name, if found
+
+
+
+ $fields.in( class/object/string )
loads all public static fields in the specified class or object
+
+
+ LinkTool
+ tool used to format hyperlinks ; this tool is somewhat unusual in that every method that takes parameters will return a new instance of the tool that is a copy of the one the method was called upon, with the additional change specified by the method call, allowing for chained calls like
+ href="$link.relative('foobar.html').param('id','25').anchor('section4')"
(which would produce href="foobar.html?id=25#section4"
)
+
+ default key
+
+ $link
+
+ configuration properties
+ uri
+ sets the default scheme, user info, host, port, path, query, and anchor elements all at once
+
+
+ scheme
+ sets the default scheme (
+ http
, https
, mailto
, ...)
+
+ info
+ sets the default user info
+
+
+ host
+ sets the default host
+
+
+ port
+ sets the default port
+
+
+ requestPath
+ sets the default path
+
+
+ params
+ sets the defaut query parameters
+
+
+ anchor
+ sets the defaut anchor
+
+
+ charset
+ sets the defaut charset
+
+
+ xhtml
+ if
+ true
, uses &
as query delimiter (this is the default), otherwise uses &
+
+ appendParameters
+ sets whether or not the
+ #setParam()
method will override existing query values for the same key or simply append the new value to a list of existing values (this is the default)
+
+ forceRelative
+ sets whether or not the
+ #createURI()
method should ignore the scheme, user, port and host values for non-opaque URIs,
+ thus making #toString
print the link as a relative one, not an absolute one ; NOTE: using #absolute()
or #relative()
+ will alter this setting accordingly on the new instances they return
+
+ methods and properties
+
+ $link.anchor
returns the anchor set for the
+ $link
+
+
+ $link.path
returns the path currently set for this $link
+
+
+
+ $link.params
returns the query data set for this
+ $link
+
+
+ $link.contextURI
returns the URI that addresses this web application, e.g. http://myserver.net/myapp ; this string may not end with a "/"
+
+
+
+ $link.contextPath
returns the context path that addresses this web application, e.g. /myapp ; this string starts with a "/" but does not end with a "/"
+
+
+
+ $link.requestPath
retrieves the path for the current request regardless of whether this is a direct request or an include by the
+ RequestDispatcher
+
+
+ $link.baseRef
returns the full URI of this template without any query data. e.g.
+ http://myserver.net/myapp/stuff/View.vm
+
+
+ $link.self
this method returns a new self-referencing
+ $link
for the current request (e.g. /myapp/stuff/View.vm
) ; however, the behavior can be changed via toolbox configuration to use absolute URIs and/or add the current request parameters
+
+
+ $link.anchor( string )
returns a new
+ $link
with the addition of the specified anchor value
+
+
+ $link.path( string )
returns a new
+ $link
with the addition of the specified path value
+
+
+ $link.relative( string )
returns a new
+ $link
with the addition of the specified relative value
+
+
+ $link.absolute( string )
returns a new
+ $link
with the addition of the specified absolute value
+
+
+ $link.params( key, value )
returns a new $link with the addition of the specified parameter
+
+
+
+ $link.encode( string )
performs URL encoding on the specified text
+
+
+ MathTool
+ tool providing math functions
+
+
+ default key
+
+ $math
+
+ methods and properties
+
+ $math.add( object, object )
returns the sum of the numbers or
+ null
if they are invalid
+
+
+ $math.sub( object, object )
returns the difference of the numbers or
+ null
if they are invalid
+
+
+ $math.mul( object, object )
returns the product of the numbers or
+ null
if they are invalid
+
+
+ $math.div( object, object )
returns the quotient of the numbers or
+ null
if they are invalid
+
+
+ $math.pow( object, object )
returns the first number raised to the power of the second or
+ null
if they are invalid
+
+
+ $math.idiv( object, object )
returns the integer division of the numbers or
+ null
if they are invalid
+
+
+ $math.mod( object, object )
returns the integer molulus operation on the numbers or
+ null
if they are invalid
+
+
+ $math.max( object, object )
returns the largest of the numbers or
+ null
if they are invalid
+
+
+ $math.min( object, object )
returns the smallest of the numbers or
+ null
if they are invalid
+
+
+ $math.abs( object )
returns the absolute value of the number or
+ null
if it is invalid
+
+
+ $math.ceil( object )
returns the smallest integer that is not less than the given number or
+ null
if it is invalid
+
+
+ $math.floor( object )
returns the integer portion of the given number or
+ null
if it is invalid
+
+
+ $math.round( object )
returns the given number rounded to the nearest whole Integer or null if it is invalid
+
+
+
+ $math.roundTo( object, decimals )
rounds a number to the specified number of decimal places
+
+
+
+ $math.random
returns a pseudo-random Double greater than or equal to 0.0 and less than 1.0
+
+
+
+ $math.random( lower, upper )
this returns a random Number within the specified range - the returned value will be greater than or equal to the first number and less than the second number - if both arguments are whole numbers then the returned number will also be, otherwise a double will be returned
+
+
+
+ $math.toInteger( object )
converts an object with a numeric value into an
+ Integer
; valid formats are Number
or a string representation of a number
+
+
+ $math.toDouble( object )
converts an object with a numeric value into a
+ Double
; valid formats are Number
or a string representation of a number
+
+
+ $math.toNumber( object )
converts an object with a numeric value into a
+ Number
; valid formats are Number
or a string representation of a number
+
+ NumberTool
+ tool used to format numbers
+
+
+ default key
+
+ $number
+
+ configuration properties
+ format
+ default number format (depends upon the default locale, '#0.0' for en_US locale)
+
+
+ locale
+ default locale
+
+
+ methods and properties
+
+ $number.format
returns or sets the pattern or style to be used for formatting numbers when none is specified
+
+
+
+ $number.locale
returns or sets the default locale
+
+
+
+ $number.format( [ format/style, ] object [ , locale ] )
formats the given number using the default or specified format or style, and the default or provided locale ;
+ style
is one of currency
, integer
, number
, percent
+
+
+ $number.currency( object )
convenience method equivalent to
+ $number.format("currency", $foo)
+
+
+ $number.integer( object )
convenience method equivalent to
+ $number.format("integer", $foo)
+
+
+ $number.number( object )
convenience method equivalent to
+ $number.format("number", $foo)
+
+
+ $number.percent( object )
convenience method equivalent to
+ $number.format("percent", $foo)
+
+ RenderTool
+ tool that exposes methods to evaluate the given strings as VTL (Velocity Template Language) using either a pre-configured context or one you provide directly
+
+
+ default key
+
+ $render
+
+ configuration properties
+ parse.depth
+ default depth for recursive evaluation (default: 20)
+
+
+ catch.exceptions
+ whether to catch exceptions during rendering (defaults to
+ true
+
+ forceThreadSafe
+ whether to force a thread-safe evaluation (defaults to
+ true
)
+
+ methods and properties
+
+ $render.eval( string )
evaluates a String containing VTL using the current context, and returns the result as a String
+
+
+
+ $reder.recurse( string )
recursively evaluates a String containing VTL using the current context, and returns the result as a String
+
+
+ ResourceTool
+ tool for accessing ResourceBundles and formatting messages therein ; most methods return a new object that has mostly the same methods as the original, allowing you to build up parameters elegantly and simply, rather than try to remember how to use methods with many parameters that must be in a specific order: so, you can access a resource with the key
+ 'hello.whoever'
in the 'otherStuff'
bundle with one message argument like this: $text.hello.whoever.bundle('otherStuff').insert('World')
instead of like this: $text.get('hello.whoever','otherStuff', $null, 'World')
+
+
+ default key
+
+ $text
+
+ configuration properties
+ defaultBundle
+ default bundle
+
+
+ bundles
+ coma-separated list of bundles (the first one being used as the default)
+
+
+ locale
+ current locale
+
+
+ defaultLocale
+ default locale
+
+
+ methods and properties
+
+ $text.key
returns the resource with the specified name, if it exists
+
+
+
+ $text.prefix.keys
returns a list of the available keys starting with the given prefix
+
+
+
+ $text.key.bundle( bundle )
returns the resource with the specified name in the specified bundle, if it exists
+
+
+
+ $text.key.locale( locale )
returns a new $text that will try to find the resource with the specified name for the specified locale
+
+
+
+ $text.key.insert( value [ , value ... ] )
Returns the named resource with the specified values inserted
+
+
+
+ $text.locale
returns or sets the current locale
+
+
+ SortTool
+ tool used to sort collections
+
+
+ default key
+
+ $sorter
+
+ methods and properties
+
+ $sorter.sort( collection [ , property / property list ] )
sorts the values of the specified
+ Collection
, Map
, or array of Objects
, either by their natural order or according to the values returned by the specified property or list of properties
+
+ XmlTool
+ tool used for reading/navigating XML files; this uses dom4j under the covers to provide complete XPath support for traversing XML files
+
+
+ default key
+
+ $xml
+
+ configuration properties
+ file
+ target XML file
+
+
+ methods and properties
+
+ $xml.attr( string )
returns the value of the specified attribute for the first/sole Node in the internal Node list for this instance, if that Node is an Element; if it is a non-Element node type or there is no value for that attribute in this element, then this will return
+ null
+
+
+ $xml.attributes()
returns a Map of all attributes for the first/sole Node held internally by this instance; if that Node is not an Element, this will return
+ null
+
+
+ $xml.children()
returns a new XmlTool instance that wraps all the child Elements of all the current internally held nodes that are Elements themselves
+
+
+
+ $xml.find( xpath )
performs an XPath selection on the current set of Nodes held by this instance and returns a new instance that wraps those results; if the specified value is
+ null
or this instance does not currently hold any nodes, then this will return null
; if the specified value, when converted to a string, does not contain a '/' character, then it has "//" prepended to it; this means that a call to $xml.find("a")
is equivalent to calling $xml.find("//a")
; the full range of XPath selectors is supported here
+
+
+ $xml.first
returns a new instance that wraps only the first Node from this instance's internal Node list
+
+
+
+ $xml.last
returns a new instance that wraps only the last Node from this instance's internal Node list
+
+
+
+ $xml.name
asks
+ get(Object)
for "name"; if none, this will return the result of getNodeName()
+
+
+ $xml.nodeName
returns the name of the root node; if the internal Node list has more than one Node, it will only return the name of the first node in the list
+
+
+
+ $xml.parent
returns a new XmlTool instance that wraps the parent Element of the first/sole Node being wrapped by this instance
+
+
+
+ $xml.path
returns the XPath that identifies the first/sole Node represented by this instance
+
+
+
+ $xml.text
returns the concatenated text content of all the internally held nodes; obviously, this is most useful when only one node is held
+
+
+
+ $xml.get( number )
returns a new instance that wraps the specified Node from this instance's internal Node list
+
+
+
+ $xml.name
, $xml.get( string )
this will first attempt to find an attribute with the specified name and return its value; if no such attribute exists or its value is
+ null
, this will attempt to convert the given value to a Number and get the result of get(Number)
; if the number conversion fails, then this will convert the object to a string; if that string does not start contain a '/', it appends the result of getPath()
and a '/' to the front of it; finally, it delegates the string to the find(String)
method and returns the result of that
+
+
+ $xml.empty
returns
+ true
if there are no Nodes internally held by this instance
+
+
+ $xml.iterator()
returns an Iterator that returns new XmlTool instances for each Node held internally by this instance; this allows VTL like
+ #foreach($node in $xml)...#end
+
+
+ $xml.node()
returns the first/sole Node from this instance's internal Node list, if any
+
+
+
+ $xml.parents()
returns a new XmlTool instance that wraps the parent Elements of each of the Nodes being wrapped by this instance; this does not return all ancestors, just the immediate parents
+
+
+
+ $xml.parse( string )
accepts XML strings. If the XML is valid, it will return a new XmlTool instance with the XML's root as its internal node
+
+
+
+ $xml.read( filename/URL )
returns
+ null
if safe mode is on; otherwise this will accept url pointing to an XML document; it will then parse that document and return a new instance with that document's root element as its node
+
+
+ $xml.size()
returns the number of Nodes internally held by this instance
+
+
+
+ $xml.toString()
if this instance has no XML Nodes, then this returns the result of super.toString(); otherwise, it returns the XML (as a string) of all the internally held nodes that are not Attributes; for attributes, only the value is used
+
+
AbstractSearchTool | +this tool is meant to be extended by a class defining the protected List executeQuery(Object crit) Java method; it allows doing "searching" and robust
+ pagination of search results; the goal here is to provide a simple and uniform API for "search tools" that can be used in velocity templates (or even a standard Search.vm template);
+ in particular, this class provides good support for result pagination and some very simple result caching |
+ |
---|---|---|
default key | +$search |
+ |
scope | +request scope | +|
methods and properties | +all methods and properties from the PagerTool are inherited |
+ |
$search.criteria |
+ returns or sets the current search criteria | +|
BrowserTool | +browser-sniffing tool; it defines properties that are used to test the client browser, operating system, device, language... apart from properties related to browser version and language, all properties are booleans. | +|
default key | +$browser |
+ |
scope | +request or session scope, session scope advised (and enabled by default) | +|
configuration properties | +languagesFilter | +an optional coma-separated list of admissible languages in the webapp | +
methods and properties | +$browser.languageFilter |
+ returns or sets the current languages filter | +
$browser.version |
+ returns browser version | +|
$browser.majorVersion |
+ returns browser major version | +|
$browser.minorVersion |
+ returns browser minor version | +|
$browser.geckoVersion |
+ version of te Gecko rendering engine for browsers belonging to the Mozilla family | +|
$browser.browser |
+ tests for the specified browser, among: mosaic netscape nav2 nav3 nav4 nav4up nav45 nav45up nav6 nav6up navgold firefox safari ie ie3 ie4 ie4up ie5 ie5up ie55 ie55up ie6 ie6up ie7 ie7up ie8 ie8up opera opera3 opera4 opera5 opera6 opera7 opera8 opera9 lynx links w3m aol aol3 aol4 aol5 aol6 neoplanet neoplanet2 amaya icab avantgo emacs mozilla gecko webtv staroffice java hotjava httpclient lobo lotusnotes konqueror galeon kmeleon chrome |
+ |
$browser.OS |
+ tests for the specified operating system, among: win16 win3x win31 win95 win98 winnt windows win32 winme win2k winxp vista dotnet mac macosx mac68k macppc os2 unix sun sun4 sun5 suni86 irix irix5 irix6 hpux hpux9 hpux10 aix aix1 aix2 aix3 aix4 linux sco unixware mpras reliant dec sinix freebsd bsd vms x11 amiga |
+ |
$browser.device |
+ tests for the specified handled device, among: palm audrey iopener wap blackberry |
+ |
$browser.feature |
+ tests for the given feature, among: javascript css css1 css2 dom0 dom1 dom2 |
+ |
$browser.robot |
+ tests for special request is issued by a known robot | +|
$browser.robot |
+ tests for known robots: wget getright yahoo altavista lycos infoseek lwp webcrawler linkexchange slurp google java |
+ |
$browser.preferredLanguageTag |
+ returns the browser's preferred langage tag (a string like 'en', 'da', 'en-US', ...), optionnaly affected by the languagesFilter configuration property | +|
$browser.preferredLocale |
+ returns the browser's preferred locale | +|
CookieTool | +tool used to read and set cookies | +|
default key | +$cookies |
+ |
scope | +request | +|
methods and properties | +$cookies.add( Cookie ) |
+ Adds the cookie to the current servlet response; this does NOT add it to the current request | +
$cookies.add( name, value [ , expiry time ] ) |
+ adds a new Cookie with the specified name and value to the current servlet response; this does not add a Cookie to the current request | +|
$cookies.create( name, value [ , expiry time ] ) |
+ creates a new Cookie with the specified name and value; this does not add the Cookie to the response, so the created Cookie will not be set unless you do $cookies.add($myCookie) |
+ |
$cookies.delete( name ) |
+ instructs the browser to remove the specified cookie by setting it with a Max-Age of 0 | +|
$cookies.all |
+ returns a list of Cookies for this request | +|
$cookies.name , $cookies.get( name ) |
+ returns the Cookie with the specified name, if it exists | +|
$cookies.toString() |
+ if there are no Cookies in the request, this returns the standard Object.toString output; otherwise, it returns a pretty printed list of cookie names and values | +|
ImportTool | +general-purpose text-importing view tool for templates | +|
default key | +$import |
+ |
scope | +request | +|
methods and properties | +$import.read( url ) |
+ returns the content read from the specified URL | +
IncludeTool | +tool allowing for transparent content negotiation in a manner mimicking Apache httpd's MultiViews; reads the default language out of the ViewToolContext as org.apache.velocity.tools.view.i18n.defaultLanguage ; please note that it does NOT do the actual #include or #parse for you, but is merely to aid in include content negotiation |
+ |
default key | +$include |
+ |
scope | +request or session scope | +|
configuration properties | +org.apache.velocity.tools.view.i18n.defaultLanguage | +this property is not searched directly in the provided tool's properties, but looked first at the Velocity context, then the servlet context, then lastly at the JVM default; + this "narrow scope to wide scope" pattern makes it easy to setup language overrides at different levels within your application | +
methods and properties | +$include.exists( name [ , locale ] ) |
+ checks whether or not a resource is available with the specified name and, if provided, specified language suffix | +
$include.find( name [ , locale / language code ] ) |
+ returns the localized name for the specified resource, with the specified Locales language suffix if specified; if one for that language is unavailable, then it will "widen" the language until one is found; if none is found at all, the name parameter is returned | +|
LinkTool | +tool used to format hyperlinks ; this tool is somewhat unusual in that every method that takes parameters will return a new instance of the tool that is a copy of the one the method was called upon, with the additional change specified by the method call, allowing for chained calls like href="$link.relative('foobar.html').param('id','25').anchor('section4')" (which would produce href="foobar.html?id=25#section4" ) |
+ |
default key | +$link |
+ |
scope | +request | +|
configuration properties | +includeRequestParams | +controls whether or not this tool starts off with all parameters from the last request automatically; default is false |
+
methods and properties | +all methods and properties from the generic LinkTool are inherited |
+ |
$link.includeRequestParams |
+ returns or sets the includeRequestParams flag | +|
$link.requestPath |
+ returns the path for the current request, regardless of whether this is a direct request or an include by the RequestDispatcher | +|
$link.addRequestParams( [ amongThisOne [ , andThisOne ... ] ] ) |
+ Adds the specified parameters (if they exist) from the current request to the query data of a copy of this instance; if no parameters are specified, then all of the current request's parameters will be added | +|
$link.addRequestParamsExcept( [ exceptThisOne [ , andThisOne ... ] ] ) |
+ Adds all of the current request's parameters to this link's query data except for those whose keys match any of the specified strings | +|
$link.addMissingRequestParams( [ exceptThisOne [ , andThisOne ... ] ] ) |
+ adds all of the current request's parameters to this link's query data except for those whose keys match any of the specified strings or already have a value set for them in the current instance | +|
PagerTool | +tool for doing request-based pagination of items in an a list | +|
default key | +$pager |
+ |
scope | +request | +|
configuration properties | +newItemsKey | +key name used to search for items in request attributes | +
indexKey | +key name used to search for current page index in request attributes | +|
itemsPerPageKey | +key name used to search for the number of items to be shown per page in request attributes | +|
slipSizeKey | +key name used to search for the max number of page indices to show in request attributes | +|
itemsPerPage | +number of items per page (defaults to 10) | +|
slipsize | +maximum number of page indices to show (defaults to 20) | +|
methods and properties | +$pager.newItemsKey |
+ returns or sets the key name used to search for items in request attributes | +
$pager.indexKey |
+ returns or sets the key name used to search for the first index in the current page in request attributes | +|
$pager.itemsPerPageKey |
+ returns or sets the key name used to search for the number of items to be shown per page in request attributes | +|
$pager.slipSizeKey |
+ returns or sets the key name used to search for the max number of page indices to show in request attributes | +|
$pager.items |
+ returns or sets the current list of items | +|
$pager.index |
+ returns or sets the first index in the current page (differs from $index.firstIndex in that it is not adjusted to fit the reality of the items available) |
+ |
$pager.itemsPerPage |
+ returns or sets the number of items to show per page (defaults to 10) | +|
$pager.slipSize |
+ returns or sets the maximum number of page indices to show (defaults to 20) | +|
$pager.hasItems() |
+ checks whether or not the result list is empty | +|
$pager.firstIndex |
+ returns the first index in the current page (as determined by the current index, items per page, and the number of items; differs from $index.index in that it is adjusted to fit the reality of the items available) |
+ |
$pager.lastIndex |
+ returns the index of the last item on the current page of results (as determined by the current index, items per page, and the number of items) | +|
$pager.prevIndex |
+ return the index for the previous page of items (as determined by the current index, items per page, and the number of items) | +|
$pager.nextIndex |
+ returns the index for the next page of items (as determined by the current index, items per page, and the number of items) | +|
$pager.page |
+ returns the current page of search items | +|
$pager.pageDescription |
+ returns a description of the current page ("1 of n") | +|
$pager.pageNumber |
+ returns the page number for the current index | +|
$pager.pageNumber( integer ) |
+ returns the page number for the specified index | +|
$pager.pagesAvailable |
+ returns the number of pages that can be made from this list given the set number of items per page | +|
$pager.total |
+ returns the total number of items available | +|
$pager.slip |
+ returns a Sliding List of Indices for Pages of items | +|
ParameterTool | +tool used to parse request parameters | +|
default key | +$params |
+ |
scope | +request | +|
methods and properties | +$params.exists( name ) |
+ checks whether given request parameter exists | +
$params.name , $params.get( name ) , $params.getString( name [ , alternate ] ) |
+ returns the parameter with the specified key as a string, if it exists; otherwise, returns the specified alternate value if specified | +|
$params.getBoolean( name [ , alternate ] ) |
+ returns the parameter with the specified key as a java.lang.Boolean, if it exists; otherwise, returns the specified alternate Boolean if specified | +|
$params.getNumber( name [ , alternate ] ) |
+ returns the parameter with the specified key as a java.lang.Number, if it exists; otherwise, returns the specified alternate Number if specified | +|
$params.getDouble( name [ , alternate ] ) |
+ returns the parameter with the specified key as a java.lang.Double, if it exists; otherwise, returns the specified alternate Double if specified | +|
$params.getInteger( name [ , alternate ] ) |
+ returns the parameter with the specified key as a java.lang.Integer, if it exists; otherwise, returns the specified alternate Integer if specified | +|
$params.getLocale( name [ , alternate ] ) |
+ returns the parameter with the specified key as a java.util.Locale, if it exists; otherwise, returns the specified alternate Locale if specified | +|
$params.getStrings( name ) |
+ returns the parameter(s) with the specified key in an array of strings, if any exist; otherwise, returns null |
+ |
$params.getBooleans( name ) |
+ returns the parameter(s) with the specified key in an array of java.lang.Boolean, if any exist; otherwise, returns null |
+ |
$params.getNumbers( name ) |
+ returns the parameter(s) with the specified key in an array of java.lang.Number, if any exist; otherwise, returns null |
+ |
$params.getDoubles( name ) |
+ returns the parameter(s) with the specified key in an array of java.lang.Doubles, if any exist; otherwise, returns null |
+ |
$params.getIntegers( name ) |
+ returns the parameter(s) with the specified key in an array of java.lang.Integers, if any exist; otherwise, returns null |
+ |
$params.all |
+ returns the map of all parameters available for the current request | +|
ViewContextTool | +extension of the generic ContextTool that includes keys and values from the HttpServletRequest, HttpSession and ServletContext attributes | +|
default key | +$context |
+ |
scope | +request | +|
methods and properties | +all methods and properties from the generic ContextTool are inherited |
+