org.apache.velocity.tools.view.tools
Class ViewResourceTool
java.lang.Object
org.apache.velocity.tools.generic.ResourceTool
org.apache.velocity.tools.view.tools.ViewResourceTool
public class ViewResourceTool
- extends ResourceTool
Tool for accessing ResourceBundles and formatting messages therein.
Template example(s):
$text.foo -> bar
$text.hello.world -> Hello World!
#set( $otherText = $text.bundle('otherBundle') )
$otherText.foo -> woogie
$otherText.bar -> The args are {0} and {1}.
$otherText.bar.insert(4) -> The args are 4 and {1}.
$otherText.bar.insert(4,true) -> The args are 4 and true.
Toolbox configuration example:
<tool>
<key>text</key>
<class>org.apache.velocity.tools.view.tools.ViewResourceTool</class>
<parameter name="bundles" value="resources,com.foo.moreResources"/>
</tool>
This comes in very handy when internationalizing templates.
Note that the default resource bundle baseName is "resources", and
the default locale is the result of HttpServletRequest.getLocale().
The default bundle baseName can be overridden as shown above.
Also, be aware that very few performance considerations have been made
in this initial version. It should do fine, but if you have performance
issues, please report them to dev@velocity.apache.org, so we can make
improvements.
This tool is NOT meant to be used in either application or
session scopes of a servlet environment.
- Since:
- VelocityTools 1.3
- Version:
- $Revision: 497990 $ $Date: 2006-11-27 10:49:37 -0800 (Mon, 27 Nov 2006) $
- Author:
- Nathan Bubna
Method Summary |
void |
init(java.lang.Object obj)
Initializes this instance. |
Methods inherited from class org.apache.velocity.tools.generic.ResourceTool |
bundle, configure, get, get, get, getDefaultBundle, getDefaultLocale, insert, insert, insert, insert, locale, render, setDefaultBundle, setDefaultLocale |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ViewResourceTool
public ViewResourceTool()
init
public void init(java.lang.Object obj)
- Initializes this instance.
- Parameters:
obj
- the current ViewContext
Copyright (c) 2003-2007 Apache Software Foundation