|Home > Guides > Plugin Developers Guide > Tiles Plugin|
Tiles is a templating framework designed to easily allow the creation of web application pages with a consistent look and feel. It can be used for both page decorating and componentization.
The Tiles plugin allows actions to return Tiles pages
allows actions to return Tiles pages
The following steps must be taken in order to enable tiles support within your Struts2 application:
Include the struts-tiles-plugin as a dependency in your web application. If you are using maven2, the dependency configuration will be similar to:
Register the tiles listener. This listener will typically either be the standard tiles listener (org.apache.tiles.listener.TilesListener) or the Struts2 replacement (org.apache.struts2.tiles.TilesListener). The latter provides tighter integration with Struts features such as freemarker integration.
All package definitions which require tiles support must either extend the tiles-default package or must register the Tiles Result type definition.
Configure your actions to utilize a tiles definition:
Instead of xml configuration you can use annotations
You have to define Tiles Definitons in a tiles.xml file. That can be placed in
resources or in
As from Struts 2.3.28, the plugin automatically loads all Tiles definitions matching the following pattern
tiles*.xml - you don't have to specify them via
web.xml, but you can use this option if your application is going to work in restricted servlet environment e.g. Google AppEngine. In such case, definitions will be read from provided
As from Struts version 2.5.3 it's possible accessing defined values on a
S2 prefix when defining an expression in tiles definition, e.g.:
In such case Tiles will delegate evaluation of the expression to Struts and
ValueStack will be examined to evaluate the expression.
Instead of defining new tiles definitions per supported language (i.e.:
tiles_pl.xml) you can use
I18N prefix to evaluate provided expression as a key in Struts resource bundles.
This plugin does inherits settings from Tiles configuration.
This plugin can be installed by copying the plugin jar into your application's
/WEB-INF/lib directory. No other files need to be copied or created.