Save This Page
Home » spring-framework-2.5.4 » org.springframework » web » servlet » view » velocity » [javadoc | source]
org.springframework.web.servlet.view.velocity
public class: VelocityToolboxView [javadoc | source]
java.lang.Object
   org.springframework.context.support.ApplicationObjectSupport
      org.springframework.web.context.support.WebApplicationObjectSupport
         org.springframework.web.servlet.view.AbstractView
            org.springframework.web.servlet.view.AbstractUrlBasedView
               org.springframework.web.servlet.view.AbstractTemplateView
                  org.springframework.web.servlet.view.velocity.VelocityView
                     org.springframework.web.servlet.view.velocity.VelocityToolboxView

All Implemented Interfaces:
    InitializingBean, View, BeanNameAware, ServletContextAware, ApplicationContextAware

Direct Known Subclasses:
    VelocityLayoutView

VelocityView subclass which adds support for Velocity Tools toolboxes and Velocity Tools ViewTool callbacks / Velocity Tools 1.3 init methods.

Specify a "toolboxConfigLocation", for example "/WEB-INF/toolbox.xml", to automatically load a Velocity Tools toolbox definition file and expose all defined tools in the specified scopes. If no config location is specified, no toolbox will be loaded and exposed.

This view will always create a special Velocity context, namely an instance of the ChainedContext class which is part of the view package of Velocity tools. This allows to use tools from the view package of Velocity Tools, like LinkTool, which need to be initialized with a special context that implements the ViewContext interface (i.e. a ChainedContext).

This view also checks tools that are specified as "toolAttributes": If they implement the ViewTool interface, they will get initialized with the Velocity context. This allows tools from the view package of Velocity Tools, such as LinkTool, to be defined as "toolAttributes" on a VelocityToolboxView, instead of in a separate toolbox XML file.

This is a separate class mainly to avoid a required dependency on the view package of Velocity Tools in VelocityView itself. As of Spring 2.0, this class requires Velocity Tools 1.2 or higher.

Fields inherited from org.springframework.web.servlet.view.AbstractTemplateView:
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Fields inherited from org.springframework.web.servlet.view.AbstractView:
DEFAULT_CONTENT_TYPE
Fields inherited from org.springframework.context.support.ApplicationObjectSupport:
logger
Method from org.springframework.web.servlet.view.velocity.VelocityToolboxView Summary:
createVelocityContext,   getToolboxConfigLocation,   initTool,   setToolboxConfigLocation
Methods from org.springframework.web.servlet.view.velocity.VelocityView:
autodetectVelocityEngine,   checkTemplate,   createVelocityContext,   createVelocityContext,   doRender,   exposeHelpers,   exposeHelpers,   exposeHelpers,   exposeToolAttributes,   getEncoding,   getTemplate,   getTemplate,   getVelocityEngine,   initApplicationContext,   initTool,   isCacheTemplate,   mergeTemplate,   renderMergedTemplateModel,   setCacheTemplate,   setDateToolAttribute,   setEncoding,   setNumberToolAttribute,   setToolAttributes,   setVelocityEngine,   setVelocityFormatterAttribute
Methods from org.springframework.web.servlet.view.AbstractTemplateView:
applyContentType,   renderMergedOutputModel,   renderMergedTemplateModel,   setAllowRequestOverride,   setAllowSessionOverride,   setExposeRequestAttributes,   setExposeSessionAttributes,   setExposeSpringMacroHelpers
Methods from org.springframework.web.servlet.view.AbstractUrlBasedView:
afterPropertiesSet,   getUrl,   isUrlRequired,   setUrl,   toString
Methods from org.springframework.web.servlet.view.AbstractView:
addStaticAttribute,   createRequestContext,   exposeModelAsRequestAttributes,   generatesDownloadContent,   getAttributesMap,   getBeanName,   getContentType,   getRequestContextAttribute,   getStaticAttributes,   prepareResponse,   render,   renderMergedOutputModel,   setAttributes,   setAttributesCSV,   setAttributesMap,   setBeanName,   setContentType,   setRequestContextAttribute,   toString
Methods from org.springframework.web.context.support.WebApplicationObjectSupport:
getServletContext,   getTempDir,   getWebApplicationContext,   initApplicationContext,   initServletContext,   isContextRequired,   setServletContext
Methods from org.springframework.context.support.ApplicationObjectSupport:
getApplicationContext,   getMessageSourceAccessor,   initApplicationContext,   initApplicationContext,   isContextRequired,   requiredContextClass,   setApplicationContext
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.web.servlet.view.velocity.VelocityToolboxView Detail:
 protected Context createVelocityContext(Map model,
    HttpServletRequest request,
    HttpServletResponse response) throws Exception 
    Overridden to create a ChainedContext, which is part of the view package of Velocity Tools, as special context. ChainedContext is needed for initialization of ViewTool instances.
 protected String getToolboxConfigLocation() 
    Return the Velocity Toolbox config location, if any.
 protected  void initTool(Object tool,
    Context velocityContext) throws Exception 
    Overridden to check for the ViewContext interface which is part of the view package of Velocity Tools. This requires a special Velocity context, like ChainedContext as set up by #createVelocityContext in this class.
 public  void setToolboxConfigLocation(String toolboxConfigLocation) 
    Set a Velocity Toolbox config location, for example "/WEB-INF/toolbox.xml", to automatically load a Velocity Tools toolbox definition file and expose all defined tools in the specified scopes. If no config location is specified, no toolbox will be loaded and exposed.

    The specfied location string needs to refer to a ServletContext resource, as expected by ServletToolboxManager which is part of the view package of Velocity Tools.