| org.springframework.web.servlet.view.velocity.VelocityView org.springframework.web.servlet.view.velocity.VelocityToolboxView org.springframework.web.servlet.view.velocity.VelocityLayoutView
VelocityLayoutView | public class VelocityLayoutView extends VelocityToolboxView (Code) | | 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.
author: Darren Davison author: Juergen Hoeller since: 1.2 See Also: VelocityLayoutView.setLayoutUrl See Also: VelocityLayoutView.setLayoutKey See Also: VelocityLayoutView.setScreenContentKey |
Method Summary | |
protected void | checkTemplate() Overrides VelocityView.checkTemplate() to additionally check
that both the layout template and the screen content template can be loaded. | protected void | doRender(Context context, HttpServletResponse response) 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). | public void | setLayoutKey(String layoutKey) Set the context key used to specify an alternate layout to be used instead
of the default layout. | public void | setLayoutUrl(String layoutUrl) Set the layout template to use. | public void | setScreenContentKey(String screenContentKey) Set the name of the context key that will hold the content of
the screen within the layout template. |
checkTemplate | protected void checkTemplate() throws ApplicationContextException(Code) | | 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.
|
doRender | protected void doRender(Context context, HttpServletResponse response) throws Exception(Code) | | 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.
|
setLayoutKey | public void setLayoutKey(String layoutKey)(Code) | | 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
VelocityLayoutView.DEFAULT_LAYOUT_KEY "layout" , as illustrated above.
Parameters: layoutKey - the name of the key you wish to use in yourscreen content templates to override the layout template |
setScreenContentKey | public void setScreenContentKey(String screenContentKey)(Code) | | 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
VelocityLayoutView.DEFAULT_SCREEN_CONTENT_KEY "screen_content" :
accessed in VTL as $screen_content .
Parameters: screenContentKey - the name of the screen content key to use |
Methods inherited from org.springframework.web.servlet.view.velocity.VelocityView | protected VelocityEngine autodetectVelocityEngine() throws BeansException(Code)(Java Doc) protected void checkTemplate() throws ApplicationContextException(Code)(Java Doc) protected Context createVelocityContext(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected Context createVelocityContext(Map model) throws Exception(Code)(Java Doc) protected void doRender(Context context, HttpServletResponse response) throws Exception(Code)(Java Doc) protected void exposeHelpers(Map model, HttpServletRequest request) throws Exception(Code)(Java Doc) protected void exposeHelpers(Context velocityContext, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) protected void exposeHelpers(Context velocityContext, HttpServletRequest request) throws Exception(Code)(Java Doc) protected void exposeToolAttributes(Context velocityContext, HttpServletRequest request) throws Exception(Code)(Java Doc) protected String getEncoding()(Code)(Java Doc) protected Template getTemplate() throws Exception(Code)(Java Doc) protected Template getTemplate(String name) throws Exception(Code)(Java Doc) protected VelocityEngine getVelocityEngine()(Code)(Java Doc) protected void initApplicationContext() throws BeansException(Code)(Java Doc) protected void initTool(Object tool, Context velocityContext) throws Exception(Code)(Java Doc) protected boolean isCacheTemplate()(Code)(Java Doc) protected void mergeTemplate(Template template, Context context, HttpServletResponse response) throws Exception(Code)(Java Doc) protected void renderMergedTemplateModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception(Code)(Java Doc) public void setCacheTemplate(boolean cacheTemplate)(Code)(Java Doc) public void setDateToolAttribute(String dateToolAttribute)(Code)(Java Doc) public void setEncoding(String encoding)(Code)(Java Doc) public void setNumberToolAttribute(String numberToolAttribute)(Code)(Java Doc) public void setToolAttributes(Properties toolAttributes)(Code)(Java Doc) public void setVelocityEngine(VelocityEngine velocityEngine)(Code)(Java Doc) public void setVelocityFormatterAttribute(String velocityFormatterAttribute)(Code)(Java Doc)
|
|
|