With Tiles 2.1 it is possible to use old Struts-Tiles definition files, since 1.1 version.
To use this feature it is needed to:
If you are using Java-based configuration, override the createDefinitionsReader method this way:
@Override protected DefinitionsReader createDefinitionsReader(Object context, TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory) { return new CompatibilityDigesterDefinitionsReader(); }
You need to add a renderer for the "page" attribute type, that is in fact the "template" type. So override the registerAttributeRenderers method.
@Override protected void registerAttributeRenderers( BasicRendererFactory rendererFactory, Object context, TilesApplicationContext applicationContext, TilesRequestContextFactory contextFactory, TilesContainer container, AttributeEvaluator evaluator) { super.registerAttributeRenderers(rendererFactory, context, applicationContext, contextFactory, container, evaluator); TemplateAttributeRenderer templateRenderer = new TemplateAttributeRenderer(); templateRenderer.setApplicationContext(applicationContext); templateRenderer.setRequestContextFactory(contextFactory); templateRenderer.setEvaluator(evaluator); rendererFactory.registerRenderer("page", templateRenderer); }
If you are using configuration using initialization parameters in web.xml you can have to override the org.apache.tiles.definition.DefinitionsReader parameter this way:
<init-param> <param-name>org.apache.tiles.definition.DefinitionsReader</param-name> <param-value>org.apache.tiles.compat.definition.digester.CompatibilityDigesterDefinitionsReader</param-value> </init-param>
You need to add a renderer for the "page" attribute type, that is in fact the "template" type. So set the org.apache.tiles.renderer.impl.BasicRendererFactory.TYPE_RENDERERS this way:
<init-param> <param-name>org.apache.tiles.renderer.impl.BasicRendererFactory.TYPE_RENDERERS</param-name> <param-value> string,org.apache.tiles.renderer.impl.StringAttributeRenderer; definition,org.apache.tiles.renderer.impl.DefinitionAttributeRenderer; template,org.apache.tiles.renderer.impl.TemplateAttributeRenderer; page,org.apache.tiles.renderer.impl.TemplateAttributeRenderer </param-value> </init-param>
A better, and more powerful, choice is to rewrite the definition files, to use the new features of Tiles 2.1.
Most of XML elements and attributes can be translated one-to-one or many-to-one without losing functionality from the 1.1-1.3 to the 2.1 DTD version.
The new header to be put in your Tiles definitions files is:
<!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 2.1//EN" "http://tiles.apache.org/dtds/tiles-config_2_1.dtd">
Struts-Tiles | Tiles 2 |
<component-definitions> <tiles-definitions> |
<tiles-definitions> |
page path template |
template |
controllerClass controllerUrl |
preparer [1] |
The page attribute type has been removed, use template instead.
The rest of the conversion is in the table below.
Struts-Tiles | Tiles 2 |
<put> | <put-attribute> |
<putList> | <put-list-attribute> |
<add> | <add-attribute> [2] <add-list-attribute> [3] |
content value |
value |
direct="true" | type="string" |