VelocityLayoutView emulates the functionality offered by Velocity's VelocityLayoutServlet to ease page composition from different templates.
The url
property should be set to the content template
for the view, and the layout template location should be specified as
layoutUrl
property. A view can override the configured
layout template location by setting the appropriate key (the default
is "layout") in the content template.
When the view is rendered, the VelocityContext is first merged with
the content template (specified by the url
property) and
then merged with the layout template to produce the final output.
The layout template can include the screen content through a VelocityContext variable (the default is "screen_content"). At runtime, this variable will contain the rendered content template.
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | DEFAULT_LAYOUT_KEY | The default layout key . |
|||||||||
String | DEFAULT_LAYOUT_URL | The default layout url . |
|||||||||
String | DEFAULT_SCREEN_CONTENT_KEY | The default screen content key . |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.view.AbstractTemplateView
| |||||||||||
From class
org.springframework.web.servlet.view.AbstractView
|
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From interface
org.springframework.web.servlet.View
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Overrides
VelocityView.checkTemplate() to additionally check
that both the layout template and the screen content template can be loaded. | |||||||||||
Set the context key used to specify an alternate layout to be used instead
of the default layout.
| |||||||||||
Set the layout template to use.
| |||||||||||
Set the name of the context key that will hold the content of
the screen within the layout template.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Overrides the normal rendering process in order to pre-process the Context,
merging it with the screen template into a single value (identified by the
value of screenContentKey).
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.springframework.web.servlet.view.velocity.VelocityToolboxView
| |||||||||||
From class
org.springframework.web.servlet.view.velocity.VelocityView
| |||||||||||
From class
org.springframework.web.servlet.view.AbstractTemplateView
| |||||||||||
From class
org.springframework.web.servlet.view.AbstractUrlBasedView
| |||||||||||
From class
org.springframework.web.servlet.view.AbstractView
| |||||||||||
From class
org.springframework.web.context.support.WebApplicationObjectSupport
| |||||||||||
From class
org.springframework.context.support.ApplicationObjectSupport
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
org.springframework.beans.factory.BeanNameAware
| |||||||||||
From interface
org.springframework.beans.factory.InitializingBean
| |||||||||||
From interface
org.springframework.context.ApplicationContextAware
| |||||||||||
From interface
org.springframework.web.context.ServletContextAware
| |||||||||||
From interface
org.springframework.web.servlet.View
|
The default screen content key
.
Overrides VelocityView.checkTemplate()
to additionally check
that both the layout template and the screen content template can be loaded.
Note that during rendering of the screen content, the layout template
can be changed which may invalidate any early checking done here.
locale | the desired Locale that we're looking for |
---|
true
if the resource exists (or is assumed to exist);
false
if we know that it does not existException |
---|
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" )
Default key is "layout"
, as illustrated above.
layoutKey | the name of the key you wish to use in your screen content templates to override the layout template |
---|
Set the layout template to use. Default is "layout.vm"
.
layoutUrl | the template location (relative to the template root directory) |
---|
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
.
screenContentKey | the name of the screen content key to use |
---|
Overrides the normal rendering process in order to pre-process the Context, merging it with the screen template into a single value (identified by the value of screenContentKey). The layout template is then merged with the modified Context in the super class.
context | the Velocity context to use for rendering |
---|---|
response | servlet response (use this to get the OutputStream or Writer) |
Exception |
---|