public class

VelocityViewResolver

extends AbstractTemplateViewResolver
java.lang.Object
   ↳ org.springframework.context.support.ApplicationObjectSupport
     ↳ org.springframework.web.context.support.WebApplicationObjectSupport
       ↳ org.springframework.web.servlet.view.AbstractCachingViewResolver
         ↳ org.springframework.web.servlet.view.UrlBasedViewResolver
           ↳ org.springframework.web.servlet.view.AbstractTemplateViewResolver
             ↳ org.springframework.web.servlet.view.velocity.VelocityViewResolver
Known Direct Subclasses

Class Overview

Convenience subclass of UrlBasedViewResolver that supports VelocityView (i.e. Velocity templates) and custom subclasses of it.

The view class for all views generated by this resolver can be specified via the "viewClass" property. See UrlBasedViewResolver's javadoc for details.

Note: When chaining ViewResolvers, a VelocityViewResolver will check for the existence of the specified template resources and only return a non-null View object if the template was actually found.

Summary

[Expand]
Inherited Constants
From class org.springframework.web.servlet.view.UrlBasedViewResolver
From interface org.springframework.core.Ordered
[Expand]
Inherited Fields
From class org.springframework.context.support.ApplicationObjectSupport
Public Constructors
VelocityViewResolver()
Public Methods
void setDateToolAttribute(String dateToolAttribute)
Set the name of the DateTool helper object to expose in the Velocity context of this view, or null if not needed.
void setNumberToolAttribute(String numberToolAttribute)
Set the name of the NumberTool helper object to expose in the Velocity context of this view, or null if not needed.
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.
Protected Methods
AbstractUrlBasedView buildView(String viewName)
Creates a new View instance of the specified view class and configures it.
void initApplicationContext()
Subclasses can override this for custom initialization behavior.
Class requiredViewClass()
Requires VelocityView.
[Expand]
Inherited Methods
From class org.springframework.web.servlet.view.AbstractTemplateViewResolver
From class org.springframework.web.servlet.view.UrlBasedViewResolver
From class org.springframework.web.servlet.view.AbstractCachingViewResolver
From class org.springframework.web.context.support.WebApplicationObjectSupport
From class org.springframework.context.support.ApplicationObjectSupport
From class java.lang.Object
From interface org.springframework.context.ApplicationContextAware
From interface org.springframework.core.Ordered
From interface org.springframework.web.context.ServletContextAware
From interface org.springframework.web.servlet.ViewResolver

Public Constructors

public VelocityViewResolver ()

Public Methods

public void setDateToolAttribute (String dateToolAttribute)

Set the name of the DateTool helper object to expose in the Velocity context of this view, or null if not needed. DateTool is part of Velocity Tools 1.0.

See Also

public void setNumberToolAttribute (String numberToolAttribute)

Set the name of the NumberTool helper object to expose in the Velocity context of this view, or null if not needed. NumberTool is part of Velocity Tools 1.1.

See Also

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.

Note: Specifying a toolbox config location will lead to VelocityToolboxView instances being created.

See Also

Protected Methods

protected AbstractUrlBasedView buildView (String viewName)

Creates a new View instance of the specified view class and configures it. Does not perform any lookup for pre-defined View instances.

Spring lifecycle methods as defined by the bean container do not have to be called here; those will be applied by the loadView method after this method returns.

Subclasses will typically call super.buildView(viewName) first, before setting further properties themselves. loadView will then apply Spring lifecycle methods at the end of this process.

Parameters
viewName the name of the view to build
Returns
  • the View instance
Throws
Exception

protected void initApplicationContext ()

Subclasses can override this for custom initialization behavior.

The default implementation is empty. Called by initApplicationContext(org.springframework.context.ApplicationContext).

protected Class requiredViewClass ()

Requires VelocityView.