This project has retired. For details please refer to its Attic page.
Apache Tiles - Framework - Expression Language (EL) support Fork me on GitHub

Expression Language support

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.

Configuration

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.

Unified EL support

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:

  • The template name will be taken from the "layout" attribute, searched in every scope.
  • The body will be taken from the "body" attribute in request scope.

MVEL Support

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:

  • The template name will be taken from the "layout" attribute, searched in every scope.
  • The body will be taken from the "body" attribute in request scope.

OGNL Support

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:

  • The template name will be taken from the "layout" attribute, searched in every scope.
  • The body will be taken from the "body" attribute in request scope.