spring-framework / org.springframework.web.servlet.view.tiles3 / TilesConfigurer

TilesConfigurer

open class TilesConfigurer : ServletContextAware, InitializingBean, DisposableBean

Helper class to configure Tiles 3.x for the Spring Framework. See http://tiles.apache.org for more information about Tiles, which basically is a templating mechanism for web applications using JSPs and other template engines.

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. org.apache.tiles.extras.complete.CompleteAutoloadTilesListener for usage in web.xml.

TilesViews can be managed by any org.springframework.web.servlet.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.tiles3.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".

Note that in Tiles 3 an underscore in the name of a file containing Tiles definitions is used to indicate locale information, for example:

 <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/defs/tiles.xml</value> <value>/WEB-INF/defs/tiles_fr_FR.xml</value> </list> </property> </bean> 

Author
mick semb wever

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
3.2

See Also
TilesViewTilesViewResolver

Constructors

<init>

TilesConfigurer()

Helper class to configure Tiles 3.x for the Spring Framework. See http://tiles.apache.org for more information about Tiles, which basically is a templating mechanism for web applications using JSPs and other template engines.

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. org.apache.tiles.extras.complete.CompleteAutoloadTilesListener for usage in web.xml.

TilesViews can be managed by any org.springframework.web.servlet.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.tiles3.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".

Note that in Tiles 3 an underscore in the name of a file containing Tiles definitions is used to indicate locale information, for example:

 <bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles3.TilesConfigurer"> <property name="definitions"> <list> <value>/WEB-INF/defs/tiles.xml</value> <value>/WEB-INF/defs/tiles_fr_FR.xml</value> </list> </property> </bean> 

Functions

afterPropertiesSet

open fun afterPropertiesSet(): Unit

Creates and exposes a TilesContainer for this web application, delegating to the TilesInitializer.

destroy

open fun destroy(): Unit

Removes the TilesContainer from this web application.

setCheckRefresh

open fun setCheckRefresh(checkRefresh: Boolean): Unit

Set whether to check Tiles definition files for a refresh at runtime. Default is "false".

setCompleteAutoload

open fun setCompleteAutoload(completeAutoload: Boolean): Unit

Specify whether to apply Tiles 3.0's "complete-autoload" configuration.

See org.apache.tiles.extras.complete.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 org.apache.tiles.extras.complete.CompleteAutoloadTilesInitializer.

setDefinitions

open fun setDefinitions(vararg definitions: String): Unit

Set the Tiles definitions, i.e. the list of files containing the definitions. Default is "/WEB-INF/tiles.xml".

setDefinitionsFactoryClass

open fun setDefinitionsFactoryClass(definitionsFactoryClass: Class<out DefinitionsFactory>): Unit

Set the org.apache.tiles.definition.DefinitionsFactory implementation to use. Default is org.apache.tiles.definition.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 java.net.URL source objects, unless you configure a different TilesContainerFactory.

setPreparerFactoryClass

open fun setPreparerFactoryClass(preparerFactoryClass: Class<out PreparerFactory>): Unit

Set the org.apache.tiles.preparer.factory.PreparerFactory implementation to use. Default is org.apache.tiles.preparer.factory.BasicPreparerFactory, creating shared instances for specified preparer classes.

Specify SimpleSpringPreparerFactory to autowire org.apache.tiles.preparer.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).

setServletContext

open fun setServletContext(servletContext: ServletContext): Unit

setTilesInitializer

open fun setTilesInitializer(tilesInitializer: TilesInitializer): Unit

Configure Tiles using a custom TilesInitializer, typically specified as an inner bean.

Default is a variant of org.apache.tiles.startup.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.

setUseMutableTilesContainer

open fun setUseMutableTilesContainer(useMutableTilesContainer: Boolean): Unit

Set whether to use a MutableTilesContainer (typically the CachingTilesContainer implementation) for this application. Default is "false".

setValidateDefinitions

open fun setValidateDefinitions(validateDefinitions: Boolean): Unit

Set whether to validate the Tiles XML definitions. Default is "true".