|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.velocity.tools.ToolManager org.apache.velocity.tools.view.ViewToolManager
public class ViewToolManager
Manages tools for web applications. This simplifies the process
of getting a tool-populated Velocity context for merging with templates.
It allows for both direct configuration by passing in a FactoryConfiguration
or having one in the ServletContext attributes under
ServletUtils.CONFIGURATION_KEY
, as well as configuration
via a tools.xml or tools.properties file in
either the classpath or the local file system.
Field Summary | |
---|---|
private boolean |
appToolsPublished
|
static java.lang.String |
CREATE_SESSION_PROPERTY
|
private boolean |
createSession
|
static java.lang.String |
DEFAULT_TOOLBOX_KEY
|
static java.lang.String |
PUBLISH_TOOLBOXES_PROPERTY
|
private boolean |
publishToolboxes
|
protected javax.servlet.ServletContext |
servletContext
|
private java.lang.String |
toolboxKey
|
Fields inherited from class org.apache.velocity.tools.ToolManager |
---|
factory, velocity |
Constructor Summary | |
---|---|
ViewToolManager(javax.servlet.ServletContext app)
Constructs an instance already configured to use the ConfigurationUtils.getAutoLoaded()() configuration
and any configuration specified via a "org.apache.velocity.tools"
system property. |
|
ViewToolManager(javax.servlet.ServletContext app,
boolean includeDefaults)
|
|
ViewToolManager(javax.servlet.ServletContext app,
boolean autoConfig,
boolean includeDefaults)
|
Method Summary | |
---|---|
protected void |
addToolboxes(ToolContext context)
|
void |
autoConfigure(boolean includeDefaults)
|
void |
configure(FactoryConfiguration config)
|
ViewToolContext |
createContext(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
ToolContext |
createContext(java.util.Map<java.lang.String,java.lang.Object> toolProps)
|
protected FactoryConfiguration |
findConfig(java.lang.String path)
|
boolean |
getCreateSession()
|
boolean |
getPublishToolboxes()
|
protected Toolbox |
getSessionToolbox()
|
java.lang.String |
getToolboxKey()
|
protected boolean |
hasSessionTools()
|
void |
prepareContext(ViewToolContext context,
javax.servlet.http.HttpServletRequest request)
|
private void |
publishToolbox(javax.servlet.ServletRequest request)
|
void |
publishToolboxes(javax.servlet.http.HttpServletRequest request)
Places the Scope.REQUEST Toolbox (if any)
into the HttpServletRequest attributes using
Toolbox.KEY as the key, places the Scope.SESSION
Toolbox (if any) into the attributes of the HttpSession (if any)
then ensures that the Scope.APPLICATION Toolbox (if any)
has been placed in the ServletContext attributes. |
void |
publishToolboxes(javax.servlet.ServletRequest request)
Places the Scope.REQUEST Toolbox (if any)
into the ServletRequest attributes using
Toolbox.KEY as the key. |
void |
setCreateSession(boolean create)
Sets whether or not a new HttpSession should be created when there are session scoped tools to be stored in the session, but no session has been created yet. |
void |
setPublishToolboxes(boolean publish)
Sets whether or not the creation of a new ViewToolContext
should make the various scoped Toolbox instances available
publically via the HttpServletRequest/HttpSession/ServletContext
attributes or simply add the Toolbox instances directly to the
context. |
void |
setToolboxKey(java.lang.String key)
Sets a new attribute key to be used for publishing each Toolbox . |
protected void |
unpublishApplicationTools()
Removes any published Scope.APPLICATION Toolbox. |
protected void |
updateGlobalProperties()
Checks the internal ToolboxFactory for any changes to
the createSession or publishToolboxes settings. |
Methods inherited from class org.apache.velocity.tools.ToolManager |
---|
configure, createContext, createToolbox, debug, getApplicationToolbox, getLog, getRequestToolbox, getToolboxFactory, getUserCanOverwriteTools, getVelocityEngine, hasApplicationTools, hasRequestTools, hasTools, prepareContext, setToolboxFactory, setUserCanOverwriteTools, setVelocityEngine |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String CREATE_SESSION_PROPERTY
public static final java.lang.String PUBLISH_TOOLBOXES_PROPERTY
public static final java.lang.String DEFAULT_TOOLBOX_KEY
protected javax.servlet.ServletContext servletContext
private boolean createSession
private boolean publishToolboxes
private boolean appToolsPublished
private java.lang.String toolboxKey
Constructor Detail |
---|
public ViewToolManager(javax.servlet.ServletContext app)
ConfigurationUtils.getAutoLoaded()()
configuration
and any configuration specified via a "org.apache.velocity.tools"
system property.
public ViewToolManager(javax.servlet.ServletContext app, boolean includeDefaults)
public ViewToolManager(javax.servlet.ServletContext app, boolean autoConfig, boolean includeDefaults)
Method Detail |
---|
public void autoConfigure(boolean includeDefaults)
autoConfigure
in class ToolManager
public void setPublishToolboxes(boolean publish)
ViewToolContext
should make the various scoped Toolbox
instances available
publically via the HttpServletRequest/HttpSession/ServletContext
attributes or simply add the Toolbox instances directly to the
context. It is important to note that if this is set to false,
session-scoped tools will NOT be stored in the session, but instead
be recreated for each request.
publishToolboxes
,
setToolboxKey(java.lang.String)
public boolean getPublishToolboxes()
public void setToolboxKey(java.lang.String key)
Toolbox
.
setPublishToolboxes(boolean)
,
publishToolboxes
public java.lang.String getToolboxKey()
public void setCreateSession(boolean create)
publishToolboxes
public boolean getCreateSession()
protected void updateGlobalProperties()
ToolboxFactory
for any changes to
the createSession or publishToolboxes settings.
protected void unpublishApplicationTools()
Scope.APPLICATION
Toolbox.
public void configure(FactoryConfiguration config)
configure
in class ToolManager
protected FactoryConfiguration findConfig(java.lang.String path)
findConfig
in class ToolManager
protected void addToolboxes(ToolContext context)
addToolboxes
in class ToolManager
public ToolContext createContext(java.util.Map<java.lang.String,java.lang.Object> toolProps)
createContext
in class ToolManager
public ViewToolContext createContext(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
public void prepareContext(ViewToolContext context, javax.servlet.http.HttpServletRequest request)
protected boolean hasSessionTools()
protected Toolbox getSessionToolbox()
public void publishToolboxes(javax.servlet.ServletRequest request)
Scope.REQUEST
Toolbox
(if any)
into the ServletRequest
attributes using
Toolbox.KEY
as the key.
private void publishToolbox(javax.servlet.ServletRequest request)
public void publishToolboxes(javax.servlet.http.HttpServletRequest request)
Scope.REQUEST
Toolbox
(if any)
into the HttpServletRequest
attributes using
Toolbox.KEY
as the key, places the Scope.SESSION
Toolbox (if any) into the attributes of the HttpSession
(if any)
then ensures that the Scope.APPLICATION
Toolbox (if any)
has been placed in the ServletContext
attributes.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |