org.apache.velocity.tools.view
Class ViewResourceTool
java.lang.Object
org.apache.velocity.tools.generic.AbstractLockConfig
org.apache.velocity.tools.generic.LocaleConfig
org.apache.velocity.tools.generic.ResourceTool
org.apache.velocity.tools.view.ViewResourceTool
- Direct Known Subclasses:
- ViewResourceTool
@InvalidScope(value={"application","session"})
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:
<tools>
<toolbox scope="request">
<tool class="org.apache.velocity.tools.view.ViewResourceTool"
bundles="resources,com.foo.moreResources"/>
</toolbox>
</tools>
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: 544680 $ $Date: 2006-11-27 10:49:37 -0800 (Mon, 27 Nov 2006) $
- Author:
- Nathan Bubna
Method Summary |
void |
setRequest(javax.servlet.http.HttpServletRequest request)
Sets the current ServletRequest |
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()
setRequest
public void setRequest(javax.servlet.http.HttpServletRequest request)
- Sets the current
ServletRequest
- Parameters:
request
- the ServletRequest
to retrieve the default Locale from
Copyright (c) 2003-2007 Apache Software Foundation