Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.struts2.views.velocity
Class VelocityManager

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

    public class VelocityManager

extends Object

Manages the environment for Velocity result types

Field Summary
`private String[]` | `chainedContextNames` Names of contexts that will be chained on every request
`private String` | `customConfigFile`
`private static Log` | `log`
`private ObjectFactory` | `objectFactory`
`static String` | `PARENT` the parent JSP tag
`static String` | `STRUTS`
`static String` | `TAG` the current JSP tag
`private List<TagLibrary>` | `tagLibraries`
`private String` | `toolBoxLocation`
`protected org.apache.velocity.tools.view.ToolboxManager` | `toolboxManager` A reference to the toolbox manager.
`private org.apache.velocity.app.VelocityEngine` | `velocityEngine`
`private Properties` | `velocityProperties`

Constructor Summary
`VelocityManager()`

Method Summary
`private void` | `addDirective(StringBuffer sb, Class clazz)`
`private void` | `applyDefaultConfiguration(ServletContext context, Properties p)` once we've loaded up the user defined configurations, we will want to apply Struts specification configurations.
`org.apache.velocity.context.Context` | `createContext(ValueStack stack, HttpServletRequest req, HttpServletResponse res)` This method is responsible for creating the standard VelocityContext used by all WW2 velocity views.
`org.apache.velocity.app.VelocityEngine` | `getVelocityEngine()`
`Properties` | `getVelocityProperties()`
`void` | `init(ServletContext context)` initializes the VelocityManager.
`protected void` | `initToolbox(ServletContext context)` Initializes the ServletToolboxManager for this servlet's toolbox (if any).
`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 org.apache.velocity.app.VelocityEngine` | `newVelocityEngine(ServletContext context)` Instantiates a new VelocityEngine.
`protected org.apache.velocity.VelocityContext[]` | `prepareChainedContexts(HttpServletRequest servletRequest, HttpServletResponse servletResponse, Map extraContext)` constructs contexts for chaining on this request.
`private static String` | `replace(String string, String oldString, String newString)`
`void` | `setChainedContexts(String contexts)` allow users to specify via the struts.properties file a set of additional VelocityContexts to chain to the the StrutsVelocityContext.
`void` | `setContainer(Container container)`
`void` | `setCustomConfigFile(String val)`
`void` | `setObjectFactory(ObjectFactory fac)`
`void` | `setToolBoxLocation(String toolboxLocation)`
`void` | `setVelocityProperties(Properties velocityProperties)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### log

    private static final Log log

### STRUTS

    public static final String STRUTS

See Also:
  Constant Field Values

### objectFactory

    private ObjectFactory objectFactory

### PARENT

    public static final String PARENT

  the parent JSP tag

  See Also:
    Constant Field Values

### TAG

    public static final String TAG

  the current JSP tag

  See Also:
    Constant Field Values

### velocityEngine

    private org.apache.velocity.app.VelocityEngine velocityEngine

### toolboxManager

    protected org.apache.velocity.tools.view.ToolboxManager toolboxManager

  A reference to the toolbox manager.

### toolBoxLocation

    private String toolBoxLocation

### chainedContextNames

    private String[] chainedContextNames

  Names of contexts that will be chained on every request

### velocityProperties

    private Properties velocityProperties

### customConfigFile

    private String customConfigFile

### tagLibraries

    private List<TagLibrary> tagLibraries

Constructor Detail

### VelocityManager

    public VelocityManager()

Method Detail

### setObjectFactory

    public void setObjectFactory(ObjectFactory fac)

### setContainer

    public void setContainer(Container container)

### 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(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:

  - request - the current HttpServletRequest
  - response - the current HttpServletResponse
  - stack - the current `ValueStack`
  - ognl - an `OgnlTool`
  - struts - an instance of `StrutsUtil`
  - action - the current Struts action

  Returns:
    a new StrutsVelocityContext

### prepareChainedContexts

    protected org.apache.velocity.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.

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

### init

    public 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

  Parameters:
    `context` - the current servlet context

### loadConfiguration

    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

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

### setCustomConfigFile

    public void setCustomConfigFile(String val)

### setToolBoxLocation

    public void setToolBoxLocation(String toolboxLocation)

### setChainedContexts

    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

### initToolbox

    protected void initToolbox(ServletContext context)

  Initializes the ServletToolboxManager for this servlet's toolbox (if any).

### newVelocityEngine

    protected org.apache.velocity.app.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

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

### applyDefaultConfiguration

    private void applyDefaultConfiguration(ServletContext context,
                                           Properties p)

  once we've loaded up the user defined configurations, we will want to apply Struts specification configurations.
  - if Velocity.RESOURCE_LOADER has not been defined, then we will use the defaults which is a joined file, class loader for unpackaed wars and a straight class loader otherwise
  - we need to define the various Struts custom user directives such as #param, #tag, and #bodytag

  Parameters:
    `context` -
    `p` -

### addDirective

    private void addDirective(StringBuffer sb,
                              Class clazz)

### replace

    private static final String replace(String string,
                                        String oldString,
                                        String newString)

### getVelocityProperties

    public Properties getVelocityProperties()

  Returns:
    the velocityProperties

### setVelocityProperties

    public void setVelocityProperties(Properties velocityProperties)

  Parameters:
    `velocityProperties` - the velocityProperties to set

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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