With Tiles it is possible to use expression languages not only in JSP pages, but also in XML definition files.
Currently supported languages are Unified EL (as in javax.el), i.e. the language used in JSP code, MVEL and OGNL.
By default, Tiles does not use an expression language, attribute values are simply used as they are.
CompleteAutoloadTilesContainerFactory enables support of Unified EL, MVEL and OGNL as follows:
- an attribute expression starting with "MVEL:" or "OGNL:" is interpreted in one of those languages. - otherwise, the parts of the expression between the braces in ${...} are interpreted in Unified EL.
The EL language is supported since Tiles 2.1.
Let's use this example:
<definition name="test.composite.el.definition" templateExpression="${layout}" preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer"> <put-attribute name="title" value="This is a configured composite definition."/> <put-attribute name="header" value="/header.jsp"/> <put-attribute name="body" expression="${requestScope.body}"/> </definition>
Before rendering the definition:
Let's use this example:
<definition name="test.composite.mvel.definition" templateExpression="MVEL:layout" preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer"> <put-attribute name="title" value="This is a configured composite definition."/> <put-attribute name="header" value="/header.jsp"/> <put-attribute name="body" expression="MVEL:requestScope.body"/> </definition>
Before rendering the definition:
Let's use this example:
<definition name="test.composite.mvel.definition" templateExpression="OGNL:layout" preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer"> <put-attribute name="title" value="This is a configured composite definition."/> <put-attribute name="header" value="/header.jsp"/> <put-attribute name="body" expression="OGNL:requestScope.body"/> </definition>
Before rendering the definition: