类 ViewToolManager
java.lang.Object
org.apache.velocity.tools.ToolManager
org.apache.velocity.tools.view.ViewToolManager
- 直接已知子类:
VelocityView
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.- 版本:
- $Id: ToolManager.java 511959 2007-02-26 19:24:39Z nbubna $
- 作者:
- Nathan Bubna
-
字段概要
字段修饰符和类型字段说明static final Stringstatic final Stringstatic final Stringprotected jakarta.servlet.ServletContext从类继承的字段 org.apache.velocity.tools.ToolManager
factory, log, velocity -
构造器概要
构造器构造器说明ViewToolManager(jakarta.servlet.ServletContext app) Constructs an instance already configured to use any configuration specified via a "org.apache.velocity.tools" system property.ViewToolManager(jakarta.servlet.ServletContext app, boolean includeDefaults) ViewToolManager(jakarta.servlet.ServletContext app, boolean autoConfig, boolean includeDefaults) -
方法概要
修饰符和类型方法说明protected voidaddToolboxes(ToolContext context) voidautoConfigure(boolean includeDefaults) voidconfigure(FactoryConfiguration config) createContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) createContext(Map<String, Object> toolProps) protected FactoryConfigurationfindConfig(String path) booleanbooleanprotected ToolboxgetSessionToolbox(jakarta.servlet.http.HttpSession session) booleanvoidprepareContext(ViewToolContext context, jakarta.servlet.http.HttpServletRequest request) voidPublishScope.APPLICATIONToolbox.voidpublishToolboxes(jakarta.servlet.http.HttpServletRequest request) Places theScope.REQUESTToolbox(if any) into theHttpServletRequestattributes usingToolbox.KEYas the key, places theScope.SESSIONToolbox (if any) into the attributes of theHttpSession(if any) then ensures that theScope.APPLICATIONToolbox (if any) has been placed in theServletContextattributes.voidpublishToolboxes(jakarta.servlet.ServletRequest request) Places theScope.REQUESTToolbox(if any) into theServletRequestattributes usingToolbox.KEYas the key.voidsetCreateSession(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.voidsetPublishToolboxes(boolean publish) Sets whether or not the creation of a newViewToolContextshould make the various scopedToolboxinstances available publically via the HttpServletRequest/HttpSession/ServletContext attributes or simply add the Toolbox instances directly to the context.voidsetToolboxKey(String key) Sets a new attribute key to be used for publishing eachToolbox.protected voidRemoves any publishedScope.APPLICATIONToolbox.protected voidChecks the internalToolboxFactoryfor any changes to the createSession or publishToolboxes settings.从类继承的方法 org.apache.velocity.tools.ToolManager
configure, createContext, createToolbox, getApplicationToolbox, getLog, getRequestToolbox, getToolboxFactory, getUserCanOverwriteTools, getVelocityEngine, hasApplicationTools, hasRequestTools, hasTools, initLog, prepareContext, setToolboxFactory, setUserCanOverwriteTools, setVelocityEngine
-
字段详细资料
-
构造器详细资料
-
ViewToolManager
public ViewToolManager(jakarta.servlet.ServletContext app) Constructs an instance already configured to use any configuration specified via a "org.apache.velocity.tools" system property.- 参数:
app- servlet context
-
ViewToolManager
public ViewToolManager(jakarta.servlet.ServletContext app, boolean includeDefaults) -
ViewToolManager
public ViewToolManager(jakarta.servlet.ServletContext app, boolean autoConfig, boolean includeDefaults)
-
-
方法详细资料
-
autoConfigure
public void autoConfigure(boolean includeDefaults) - 覆盖:
autoConfigure在类中ToolManager
-
setPublishToolboxes
public void setPublishToolboxes(boolean publish) Sets whether or not the creation of a newViewToolContextshould make the various scopedToolboxinstances 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.- 参数:
publish- whether to publish the available toolboxes- 另请参阅:
-
publishToolboxessetToolboxKey(java.lang.String)
-
getPublishToolboxes
public boolean getPublishToolboxes() -
setToolboxKey
Sets a new attribute key to be used for publishing eachToolbox.- 参数:
key- toolbox key- 另请参阅:
-
setPublishToolboxes(boolean)publishToolboxes
-
getToolboxKey
-
setCreateSession
public 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.- 参数:
create- whether to create a new session if needed- 另请参阅:
-
publishToolboxes
-
getCreateSession
public boolean getCreateSession() -
updateGlobalProperties
protected void updateGlobalProperties()Checks the internalToolboxFactoryfor any changes to the createSession or publishToolboxes settings. -
publishApplicationTools
public void publishApplicationTools()PublishScope.APPLICATIONToolbox. -
unpublishApplicationTools
protected void unpublishApplicationTools()Removes any publishedScope.APPLICATIONToolbox. -
configure
- 覆盖:
configure在类中ToolManager
-
findConfig
- 覆盖:
findConfig在类中ToolManager
-
addToolboxes
- 覆盖:
addToolboxes在类中ToolManager
-
createContext
- 覆盖:
createContext在类中ToolManager
-
createContext
public ViewToolContext createContext(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) -
prepareContext
public void prepareContext(ViewToolContext context, jakarta.servlet.http.HttpServletRequest request) -
hasSessionTools
public boolean hasSessionTools() -
getSessionToolbox
-
getSessionToolbox
-
publishToolboxes
public void publishToolboxes(jakarta.servlet.ServletRequest request) Places theScope.REQUESTToolbox(if any) into theServletRequestattributes usingToolbox.KEYas the key.- 参数:
request- servlet request
-
publishToolboxes
public void publishToolboxes(jakarta.servlet.http.HttpServletRequest request) Places theScope.REQUESTToolbox(if any) into theHttpServletRequestattributes usingToolbox.KEYas the key, places theScope.SESSIONToolbox (if any) into the attributes of theHttpSession(if any) then ensures that theScope.APPLICATIONToolbox (if any) has been placed in theServletContextattributes.- 参数:
request- servlet request
-