Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » views » velocity » [javadoc | source]
org.apache.struts2.views.velocity
public class: VelocityManager [javadoc | source]
java.lang.Object
   org.apache.struts2.views.velocity.VelocityManager
Manages the environment for Velocity result types
Field Summary
public static final  String STRUTS     
public static final  String PARENT    the parent JSP tag 
public static final  String TAG    the current JSP tag 
protected  ToolboxManager toolboxManager    A reference to the toolbox manager. 
Constructor:
 public VelocityManager() 
Method from org.apache.struts2.views.velocity.VelocityManager Summary:
createContext,   getVelocityEngine,   getVelocityProperties,   init,   initToolbox,   loadConfiguration,   newVelocityEngine,   prepareChainedContexts,   setChainedContexts,   setContainer,   setCustomConfigFile,   setObjectFactory,   setToolBoxLocation,   setVelocityProperties
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.views.velocity.VelocityManager Detail:
 public Context createContext(ValueStack stack,
    HttpServletRequest req,
    HttpServletResponse res) 
    This method is responsible for creating the standard VelocityContext used by all WW2 velocity views. The following context parameters are defined:

 public VelocityEngine getVelocityEngine() 
 public Properties getVelocityProperties() 
 public synchronized  void init(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
 protected  void initToolbox(ServletContext context) 
    Initializes the ServletToolboxManager for this servlet's toolbox (if any).
 public Properties loadConfiguration(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 VelocityEngine newVelocityEngine(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:

    • relative to the servlet context path
    • relative to the WEB-INF directory
    • on the classpath
 protected VelocityContext[] prepareChainedContexts(HttpServletRequest servletRequest,
    HttpServletResponse servletResponse,
    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.
 public  void setChainedContexts(String contexts) 
    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
 public  void setContainer(Container container) 
 public  void setCustomConfigFile(String val) 
 public  void setObjectFactory(ObjectFactory fac) 
 public  void setToolBoxLocation(String toolboxLocation) 
 public  void setVelocityProperties(Properties velocityProperties)