org.springbyexample.web.servlet.view.tiles2
Class DynamicTilesView
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.springbyexample.web.servlet.view.tiles2.DynamicTilesView
- All Implemented Interfaces:
- BeanNameAware, InitializingBean, ApplicationContextAware, ServletContextAware, View
public class DynamicTilesView
- extends AbstractUrlBasedView
View implementation that first checks if the request is
a Tiles definition, then if it isn't tries to retrieve a default Tiles
template and uses the url to dynamically set the body.
The main template name defaults to 'mainTemplate', the
body attribute defaults to to 'body', and the delimiter is '.'
which is used for replacing a '/' in the url.
If a request is made for '/info/index.html', Spring will pass 'info/index' into the view.
The first thing will be to look for 'info/index' as a Tiles definition.
Then a template definition of '.info.mainTemplate', which if found will dynamically have a
body set on this definition. If the previous aren't found, it is assumed a root definition
exists. This would be '.mainTemplate'. If none of these exist, a TilesException will be thrown.
- Check if a Tiles definition based on the URL matches.
- Checks if a definition derived from the URL and default template name exists and then dynamically insert the body based on the URL.
- Check if there is a root template definition and then dynamically insert the body based on the URL.
- If no match is found from any process above a TilesException is thrown.
- Author:
- David Winterfeldt
Methods inherited from class org.springframework.web.servlet.view.AbstractView |
addStaticAttribute, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getStaticAttributes, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setRequestContextAttribute, writeToResponse |
DynamicTilesView
public DynamicTilesView()
setTilesDefinitionName
public void setTilesDefinitionName(String tilesDefinitionName)
- Main template name. The default is 'mainTemplate'.
- Parameters:
tilesDefinitionName
- Main template name used to lookup definitions.
setTilesBodyAttributeName
public void setTilesBodyAttributeName(String tilesBodyAttributeName)
- Tiles body attribute name. The default is 'body'.
- Parameters:
tilesBodyAttributeName
- Tiles body attribute name.
setTilesDefinitionDelimiter
public void setTilesDefinitionDelimiter(String tilesDefinitionDelimiter)
- Sets Tiles definition delimiter. For example, instead of using
the request 'info/about' to lookup the template definition
'info/mainTemplate', the default delimiter of '.'
would look for '.info.mainTemplate'
- Parameters:
tilesDefinitionDelimiter
- Optional delimiter to replace '/' in a url.
renderMergedOutputModel
protected void renderMergedOutputModel(Map model,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
- Renders output using Tiles.
- Specified by:
renderMergedOutputModel
in class AbstractView
- Throws:
Exception
Copyright © 2008 Spring by Example. All Rights Reserved.