类 ViewToolManager

java.lang.Object
org.apache.velocity.tools.ToolManager
org.apache.velocity.tools.view.ViewToolManager
直接已知子类:
VelocityView

public class ViewToolManager extends ToolManager
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
  • 字段详细资料

    • CREATE_SESSION_PROPERTY

      public static final String CREATE_SESSION_PROPERTY
      另请参阅:
    • PUBLISH_TOOLBOXES_PROPERTY

      public static final String PUBLISH_TOOLBOXES_PROPERTY
      另请参阅:
    • DEFAULT_TOOLBOX_KEY

      public static final String DEFAULT_TOOLBOX_KEY
    • servletContext

      protected jakarta.servlet.ServletContext servletContext
  • 构造器详细资料

    • 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 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. 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
      另请参阅:
    • getPublishToolboxes

      public boolean getPublishToolboxes()
    • setToolboxKey

      public void setToolboxKey(String key)
      Sets a new attribute key to be used for publishing each Toolbox.
      参数:
      key - toolbox key
      另请参阅:
    • getToolboxKey

      public String 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 internal ToolboxFactory for any changes to the createSession or publishToolboxes settings.
    • publishApplicationTools

      public void publishApplicationTools()
      Publish Scope.APPLICATION Toolbox.
    • unpublishApplicationTools

      protected void unpublishApplicationTools()
      Removes any published Scope.APPLICATION Toolbox.
    • configure

      public void configure(FactoryConfiguration config)
      覆盖:
      configure 在类中 ToolManager
    • findConfig

      protected FactoryConfiguration findConfig(String path)
      覆盖:
      findConfig 在类中 ToolManager
    • addToolboxes

      protected void addToolboxes(ToolContext context)
      覆盖:
      addToolboxes 在类中 ToolManager
    • createContext

      public ToolContext createContext(Map<String,Object> toolProps)
      覆盖:
      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

      protected Toolbox getSessionToolbox()
    • getSessionToolbox

      public Toolbox getSessionToolbox(jakarta.servlet.http.HttpSession session)
    • publishToolboxes

      public void publishToolboxes(jakarta.servlet.ServletRequest request)
      Places the Scope.REQUEST Toolbox (if any) into the ServletRequest attributes using Toolbox.KEY as the key.
      参数:
      request - servlet request
    • publishToolboxes

      public void publishToolboxes(jakarta.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.
      参数:
      request - servlet request