org.apache.struts2.views.velocity
Class VelocityManager

java.lang.Object
  extended by org.apache.struts2.views.velocity.VelocityManager

public class VelocityManager
extends java.lang.Object

Manages the environment for Velocity result types


Field Summary
static java.lang.String PARENT
          the parent JSP tag
static java.lang.String STRUTS
           
static java.lang.String TAG
          the current JSP tag
protected  org.apache.velocity.tools.view.ToolboxManager toolboxManager
          A reference to the toolbox manager.
 
Constructor Summary
protected VelocityManager()
           
 
Method Summary
 org.apache.velocity.context.Context createContext(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          This method is responsible for creating the standard VelocityContext used by all WW2 velocity views.
static VelocityManager getInstance()
          retrieve an instance to the current VelocityManager
 org.apache.velocity.app.VelocityEngine getVelocityEngine()
           
 java.util.Properties getVelocityProperties()
           
protected  void init()
          performs one-time initializations
 void init(javax.servlet.ServletContext context)
          initializes the VelocityManager.
protected  void initChainedContexts()
          allow users to specify via the struts.properties file a set of additional VelocityContexts to chain to the the StrutsVelocityContext.
protected  void initToolbox(javax.servlet.ServletContext context)
          Initializes the ServletToolboxManager for this servlet's toolbox (if any).
 java.util.Properties loadConfiguration(javax.servlet.ServletContext context)
          load optional velocity properties using the following loading strategy relative to the servlet context path relative to the WEB-INF directory on the classpath
protected  org.apache.velocity.app.VelocityEngine newVelocityEngine(javax.servlet.ServletContext context)
          

Instantiates a new VelocityEngine.

protected  org.apache.velocity.VelocityContext[] prepareChainedContexts(javax.servlet.http.HttpServletRequest servletRequest, javax.servlet.http.HttpServletResponse servletResponse, java.util.Map extraContext)
          constructs contexts for chaining on this request.
 void setVelocityProperties(java.util.Properties velocityProperties)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRUTS

public static final java.lang.String STRUTS
See Also:
Constant Field Values

PARENT

public static final java.lang.String PARENT
the parent JSP tag

See Also:
Constant Field Values

TAG

public static final java.lang.String TAG
the current JSP tag

See Also:
Constant Field Values

toolboxManager

protected org.apache.velocity.tools.view.ToolboxManager toolboxManager
A reference to the toolbox manager.

Constructor Detail

VelocityManager

protected VelocityManager()
Method Detail

getInstance

public static VelocityManager getInstance()
retrieve an instance to the current VelocityManager


getVelocityEngine

public org.apache.velocity.app.VelocityEngine getVelocityEngine()
Returns:
a reference to the VelocityEngine used by all struts velocity thingies with the exception of directly accessed *.vm pages

createContext

public org.apache.velocity.context.Context createContext(com.opensymphony.xwork2.util.ValueStack stack,
                                                         javax.servlet.http.HttpServletRequest req,
                                                         javax.servlet.http.HttpServletResponse res)
This method is responsible for creating the standard VelocityContext used by all WW2 velocity views. The following context parameters are defined:

Returns:
a new StrutsVelocityContext

prepareChainedContexts

protected org.apache.velocity.VelocityContext[] prepareChainedContexts(javax.servlet.http.HttpServletRequest servletRequest,
                                                                       javax.servlet.http.HttpServletResponse servletResponse,
                                                                       java.util.Map extraContext)
constructs contexts for chaining on this request. This method does not perform any initialization of the contexts. All that must be done in the context itself.

Parameters:
servletRequest -
servletResponse -
extraContext -
Returns:
an VelocityContext[] of contexts to chain

init

public void init(javax.servlet.ServletContext context)
initializes the VelocityManager. this should be called during the initialization process, say by ServletDispatcher. this may be called multiple times safely although calls beyond the first won't do anything

Parameters:
context - the current servlet context

loadConfiguration

public java.util.Properties loadConfiguration(javax.servlet.ServletContext context)
load optional velocity properties using the following loading strategy

Parameters:
context - the current ServletContext. may not be null
Returns:
the optional properties if struts.velocity.configfile was specified, an empty Properties file otherwise

init

protected void init()
performs one-time initializations


initToolbox

protected void initToolbox(javax.servlet.ServletContext context)
Initializes the ServletToolboxManager for this servlet's toolbox (if any).


initChainedContexts

protected void initChainedContexts()
allow users to specify via the struts.properties file a set of additional VelocityContexts to chain to the the StrutsVelocityContext. The intent is to allow these contexts to store helper objects that the ui developer may want access to. Examples of reasonable VelocityContexts would be an IoCVelocityContext, a SpringReferenceVelocityContext, and a ToolboxVelocityContext


newVelocityEngine

protected org.apache.velocity.app.VelocityEngine newVelocityEngine(javax.servlet.ServletContext context)

Instantiates a new VelocityEngine.

The following is the default Velocity configuration

  resource.loader = file, class
  file.resource.loader.path = real path of webapp
  class.resource.loader.description = Velocity Classpath Resource Loader
  class.resource.loader.class = org.apache.struts2.views.velocity.StrutsResourceLoader
 

this default configuration can be overridden by specifying a struts.velocity.configfile property in the struts.properties file. the specified config file will be searched for in the following order:

Parameters:
context - the current ServletContext. may not be null

getVelocityProperties

public java.util.Properties getVelocityProperties()
Returns:
the velocityProperties

setVelocityProperties

public void setVelocityProperties(java.util.Properties velocityProperties)
Parameters:
velocityProperties - the velocityProperties to set


Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.