org.springframework.web.servlet.view.velocity
Class VelocityLayoutViewResolver

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.view.AbstractCachingViewResolver
              extended by org.springframework.web.servlet.view.UrlBasedViewResolver
                  extended by org.springframework.web.servlet.view.AbstractTemplateViewResolver
                      extended by org.springframework.web.servlet.view.velocity.VelocityViewResolver
                          extended by org.springframework.web.servlet.view.velocity.VelocityLayoutViewResolver
All Implemented Interfaces:
Aware, ApplicationContextAware, Ordered, ServletContextAware, ViewResolver

public class VelocityLayoutViewResolver
extends VelocityViewResolver

Convenience subclass of VelocityViewResolver, adding support for VelocityLayoutView and its properties.

See VelocityViewResolver's javadoc for general usage info.

Since:
1.2.7
Author:
Juergen Hoeller
See Also:
VelocityViewResolver, VelocityLayoutView, setLayoutUrl(java.lang.String), setLayoutKey(java.lang.String), setScreenContentKey(java.lang.String)

Field Summary
 
Fields inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver
FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX
 
Fields inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
DEFAULT_CACHE_LIMIT
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Fields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
 
Constructor Summary
VelocityLayoutViewResolver()
           
 
Method Summary
protected  AbstractUrlBasedView buildView(String viewName)
          Creates a new View instance of the specified view class and configures it.
protected  Class requiredViewClass()
          Requires VelocityLayoutView.
 void setLayoutKey(String layoutKey)
          Set the context key used to specify an alternate layout to be used instead of the default layout.
 void setLayoutUrl(String layoutUrl)
          Set the layout template to use.
 void setScreenContentKey(String screenContentKey)
          Set the name of the context key that will hold the content of the screen within the layout template.
 
Methods inherited from class org.springframework.web.servlet.view.velocity.VelocityViewResolver
initApplicationContext, setDateToolAttribute, setNumberToolAttribute, setToolboxConfigLocation
 
Methods inherited from class org.springframework.web.servlet.view.AbstractTemplateViewResolver
setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpers
 
Methods inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver
canHandle, createView, getAttributesMap, getCacheKey, getContentType, getOrder, getPrefix, getRequestContextAttribute, getSuffix, getViewClass, getViewNames, isRedirectContextRelative, isRedirectHttp10Compatible, loadView, setAttributes, setAttributesMap, setContentType, setExposePathVariables, setOrder, setPrefix, setRedirectContextRelative, setRedirectHttp10Compatible, setRequestContextAttribute, setSuffix, setViewClass, setViewNames
 
Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver
clearCache, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, setCacheLimit, setCacheUnresolved
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityLayoutViewResolver

public VelocityLayoutViewResolver()
Method Detail

requiredViewClass

protected Class requiredViewClass()
Requires VelocityLayoutView.

Overrides:
requiredViewClass in class VelocityViewResolver
See Also:
VelocityLayoutView

setLayoutUrl

public void setLayoutUrl(String layoutUrl)
Set the layout template to use. Default is "layout.vm".

Parameters:
layoutUrl - the template location (relative to the template root directory)
See Also:
VelocityLayoutView.setLayoutUrl(java.lang.String)

setLayoutKey

public void setLayoutKey(String layoutKey)
Set the context key used to specify an alternate layout to be used instead of the default layout. Screen content templates can override the layout template that they wish to be wrapped with by setting this value in the template, for example:
#set( $layout = "MyLayout.vm" )

The default key is "layout", as illustrated above.

Parameters:
layoutKey - the name of the key you wish to use in your screen content templates to override the layout template
See Also:
VelocityLayoutView.setLayoutKey(java.lang.String)

setScreenContentKey

public void setScreenContentKey(String screenContentKey)
Set the name of the context key that will hold the content of the screen within the layout template. This key must be present in the layout template for the current screen to be rendered.

Default is "screen_content": accessed in VTL as $screen_content.

Parameters:
screenContentKey - the name of the screen content key to use
See Also:
VelocityLayoutView.setScreenContentKey(java.lang.String)

buildView

protected AbstractUrlBasedView buildView(String viewName)
                                  throws Exception
Description copied from class: UrlBasedViewResolver
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.

Overrides:
buildView in class VelocityViewResolver
Parameters:
viewName - the name of the view to build
Returns:
the View instance
Throws:
Exception - if the view couldn't be resolved
See Also:
UrlBasedViewResolver.loadView(String, java.util.Locale)