public class TilesConfigurer extends Object implements ServletContextAware, InitializingBean, DisposableBean
The TilesConfigurer simply configures a TilesContainer using a set of files
containing definitions, to be accessed by TilesView
instances. This is a
Spring-based alternative (for usage in Spring configuration) to the Tiles-provided
ServletContextListener
(e.g. CompleteAutoloadTilesListener
for usage in web.xml
.
TilesViews can be managed by any ViewResolver
.
For simple convention-based view resolution, consider using TilesViewResolver
.
A typical TilesConfigurer bean definition looks as follows:
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/defs/general.xml</value> <value>/WEB-INF/defs/widgets.xml</value> <value>/WEB-INF/defs/administrator.xml</value> <value>/WEB-INF/defs/customer.xml</value> <value>/WEB-INF/defs/templates.xml</value> </list> </property> </bean>The values in the list are the actual Tiles XML files containing the definitions. If the list is not specified, the default is
"/WEB-INF/tiles.xml"
.TilesView
,
TilesViewResolver
Constructor and Description |
---|
TilesConfigurer() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Creates and exposes a TilesContainer for this web application,
delegating to the TilesInitializer.
|
protected TilesInitializer |
createTilesInitializer()
Creates a new instance of
SpringTilesInitializer . |
void |
destroy()
Removes the TilesContainer from this web application.
|
void |
setCheckRefresh(boolean checkRefresh)
Set whether to check Tiles definition files for a refresh at runtime.
|
void |
setCompleteAutoload(boolean completeAutoload)
Specify whether to apply Tiles 2.2's "complete-autoload" configuration.
|
void |
setDefinitions(String... definitions)
Set the Tiles definitions, i.e.
|
void |
setDefinitionsFactoryClass(Class<? extends DefinitionsFactory> definitionsFactoryClass)
Set the
DefinitionsFactory implementation to use. |
void |
setPreparerFactoryClass(Class<? extends PreparerFactory> preparerFactoryClass)
Set the
PreparerFactory implementation to use. |
void |
setServletContext(ServletContext servletContext)
Set the
ServletContext that this object runs in. |
void |
setTilesInitializer(TilesInitializer tilesInitializer)
Configure Tiles using a custom TilesInitializer, typically specified as an inner bean.
|
void |
setUseMutableTilesContainer(boolean useMutableTilesContainer)
Set whether to use a MutableTilesContainer (typically the CachingTilesContainer
implementation) for this application.
|
void |
setValidateDefinitions(boolean validateDefinitions)
Set whether to validate the Tiles XML definitions.
|
protected final Log logger
public void setTilesInitializer(TilesInitializer tilesInitializer)
Default is a variant of DefaultTilesInitializer
,
respecting the "definitions", "preparerFactoryClass" etc properties on this configurer.
NOTE: Specifying a custom TilesInitializer effectively disables all other bean properties on this configurer. The entire initialization procedure is then left to the TilesInitializer as specified.
public void setCompleteAutoload(boolean completeAutoload)
See CompleteAutoloadTilesContainerFactory
for details on the complete-autoload mode.
NOTE: Specifying the complete-autoload mode effectively disables all other bean
properties on this configurer. The entire initialization procedure is then left
to CompleteAutoloadTilesInitializer
.
public void setDefinitions(String... definitions)
public void setCheckRefresh(boolean checkRefresh)
public void setValidateDefinitions(boolean validateDefinitions)
public void setDefinitionsFactoryClass(Class<? extends DefinitionsFactory> definitionsFactoryClass)
DefinitionsFactory
implementation to use.
Default is UnresolvingLocaleDefinitionsFactory
,
operating on definition resource URLs.
Specify a custom DefinitionsFactory, e.g. a UrlDefinitionsFactory subclass,
to customize the creation of Tiles Definition objects. Note that such a
DefinitionsFactory has to be able to handle URL
source objects,
unless you configure a different TilesContainerFactory.
public void setPreparerFactoryClass(Class<? extends PreparerFactory> preparerFactoryClass)
PreparerFactory
implementation to use.
Default is BasicPreparerFactory
, creating
shared instances for specified preparer classes.
Specify SimpleSpringPreparerFactory
to autowire
ViewPreparer
instances based on specified
preparer classes, applying Spring's container callbacks as well as applying
configured Spring BeanPostProcessors. If Spring's context-wide annotation-config
has been activated, annotations in ViewPreparer classes will be automatically
detected and applied.
Specify SpringBeanPreparerFactory
to operate on specified preparer
names instead of classes, obtaining the corresponding Spring bean from
the DispatcherServlet's application context. The full bean creation process
will be in the control of the Spring application context in this case,
allowing for the use of scoped beans etc. Note that you need to define one
Spring bean definition per preparer name (as used in your Tiles definitions).
public void setUseMutableTilesContainer(boolean useMutableTilesContainer)
MutableTilesContainer
,
CachingTilesContainer
public void setServletContext(ServletContext servletContext)
ServletContextAware
ServletContext
that this object runs in.
Invoked after population of normal bean properties but before an init
callback like InitializingBean's afterPropertiesSet
or a
custom init-method. Invoked after ApplicationContextAware's
setApplicationContext
.
setServletContext
in interface ServletContextAware
servletContext
- ServletContext object to be used by this objectInitializingBean.afterPropertiesSet()
,
ApplicationContextAware.setApplicationContext(org.springframework.context.ApplicationContext)
public void afterPropertiesSet() throws TilesException
afterPropertiesSet
in interface InitializingBean
TilesException
- in case of setup failureprotected TilesInitializer createTilesInitializer()
SpringTilesInitializer
.
Override it to use a different initializer.
public void destroy() throws TilesException
destroy
in interface DisposableBean
TilesException
- in case of cleanup failure