org.springframework.web.servlet.view.tiles
public class: TilesConfigurer [javadoc |
source]
java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.view.tiles.TilesConfigurer
All Implemented Interfaces:
InitializingBean, ServletContextAware, ApplicationContextAware
Helper class to configure Tiles 1.x for the Spring Framework. See
http://struts.apache.org
for more information about Struts Tiles, which basically is a templating
mechanism for JSP-based web applications.
NOTE: This TilesConfigurer class supports Tiles 1.x,
a.k.a. "Struts Tiles", which comes as part of Struts 1.x.
For Tiles 2.x support, check out
org.springframework.web.servlet.view.tiles2.TilesConfigurer .
The TilesConfigurer simply configures a Tiles DefinitionsFactory using
a set of files containing definitions, to be accessed by TilesView
instances.
TilesViews can be managed by any org.springframework.web.servlet.ViewResolver .
For simple convention-based view resolution, consider using
org.springframework.web.servlet.view.UrlBasedViewResolver with the
"viewClass" property set to "org.springframework.web.servlet.view.tiles.TilesView".
A typical TilesConfigurer bean definition looks as follows:
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles.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 files containing the definitions.
| Method from org.springframework.web.servlet.view.tiles.TilesConfigurer Detail: |
public void afterPropertiesSet() throws DefinitionsFactoryException {
logger.debug("TilesConfigurer: initializion started");
// initialize the configuration for the definitions factory
DefinitionsFactoryConfig factoryConfig = new DefinitionsFactoryConfig();
factoryConfig.setFactoryName("");
factoryConfig.setFactoryClassname(this.factoryClass.getName());
factoryConfig.setParserValidate(this.validateDefinitions);
if (this.definitions != null) {
String defs = StringUtils.arrayToCommaDelimitedString(this.definitions);
if (logger.isInfoEnabled()) {
logger.info("TilesConfigurer: adding definitions [" + defs + "]");
}
factoryConfig.setDefinitionConfigFiles(defs);
}
// initialize the definitions factory
createDefinitionsFactory(factoryConfig);
logger.debug("TilesConfigurer: initialization completed");
}
Initialize the Tiles definition factory.
Delegates to createDefinitionsFactory for the actual creation. |
protected DefinitionsFactory createDefinitionsFactory(DefinitionsFactoryConfig factoryConfig) throws DefinitionsFactoryException {
return TilesUtil.createDefinitionsFactory(getServletContext(), factoryConfig);
}
Create the Tiles DefinitionsFactory and expose it to the ServletContext. |
public void setDefinitions(String[] definitions) {
this.definitions = definitions;
}
Set the Tiles definitions, i.e. the list of files containing the definitions. |
public void setFactoryClass(Class factoryClass) {
this.factoryClass = factoryClass;
}
Set the factory class for Tiles. Default is I18nFactorySet. |
public void setValidateDefinitions(boolean validateDefinitions) {
this.validateDefinitions = validateDefinitions;
}
Set whether to validate the Tiles XML definitions. Default is "true". |