public class ViewToolManager extends ToolManager
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.| Modifier and Type | Field and Description |
|---|---|
static String |
CREATE_SESSION_PROPERTY |
static String |
DEFAULT_TOOLBOX_KEY |
static String |
PUBLISH_TOOLBOXES_PROPERTY |
protected javax.servlet.ServletContext |
servletContext |
factory, velocity| Constructor and Description |
|---|
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) |
| Modifier and Type | Method and Description |
|---|---|
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(Map<String,Object> toolProps) |
protected FactoryConfiguration |
findConfig(String path) |
boolean |
getCreateSession() |
boolean |
getPublishToolboxes() |
protected Toolbox |
getSessionToolbox() |
String |
getToolboxKey() |
protected boolean |
hasSessionTools() |
void |
prepareContext(ViewToolContext context,
javax.servlet.http.HttpServletRequest 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(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. |
configure, createContext, createToolbox, debug, getApplicationToolbox, getLog, getRequestToolbox, getToolboxFactory, getUserCanOverwriteTools, getVelocityEngine, hasApplicationTools, hasRequestTools, hasTools, prepareContext, setToolboxFactory, setUserCanOverwriteTools, setVelocityEnginepublic static final String CREATE_SESSION_PROPERTY
public static final String PUBLISH_TOOLBOXES_PROPERTY
public static final String DEFAULT_TOOLBOX_KEY
protected javax.servlet.ServletContext servletContext
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)
public void autoConfigure(boolean includeDefaults)
autoConfigure in class ToolManagerpublic 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(String key)
Toolbox.setPublishToolboxes(boolean),
publishToolboxespublic String getToolboxKey()
public void setCreateSession(boolean create)
publishToolboxespublic 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 ToolManagerprotected FactoryConfiguration findConfig(String path)
findConfig in class ToolManagerprotected void addToolboxes(ToolContext context)
addToolboxes in class ToolManagerpublic ToolContext createContext(Map<String,Object> toolProps)
createContext in class ToolManagerpublic 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.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.Copyright © 2002–2023 Apache Software Foundation. All rights reserved.