Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

As from Struts version 2.5.3 it's possible accessing defined I18N keys and values on a ValueStack using S2 prefix when defining an expression in tiles definition, e.g.:

Code Block
xml
xml
<definition name="home" extends="logged-in">
  <put-attribute name="title" expression="S2:home.titleactionProperty"/>
  <put-attribute name="body" value="/WEB-INF/tiles/home.jsp"/>
</definition>

In such case Tiles will delegate evaluation of the expression to Struts and first a key from I18N resources will be looked for and then ValueStack will be evaluated. If both evaluations return null, the expression will be returned.and ValueStack will be examined to evaluate the expression.

I18N

Instead of defining new tiles definitions per supported language (i.e.: tiles.xmltiles_de.xmltiles_pl.xml) you can use I18N prefix to evaluate provided expression as a key in Struts resource bundles. 

Code Block
xml
xml
<definition name="home" extends="logged-in">
  <put-attribute name="title" expression="I18N:home.title"/>
  <put-attribute name="body" value="/WEB-INF/tiles/home.jsp"/>
</definition>
Info

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 org.apache.tiles.definition.DefinitionsFactory.DEFINITIONS_CONFIG in 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 init-param.

...