Lets assume my tiles.xml file contained the following

<definition name="tiles:layout"
template="/WEB-INF/pages/layouts/default/layout.jsp">
        <put-attribute name="title"     value="Please set your page title!"
cascade="true" />
        <put-attribute name="header"
        value="/WEB-INF/pages/layouts/default/header.jsp"/>
        <put-attribute name="body"              value="" />
        <put-attribute
name="footer"   value="/WEB-INF/pages/layouts/default/footer.jsp" />
</definition>

Each JSP page we implement contains a similar fragment to this:

<tiles:insertDefinition name="tiles:layout">    
        <tiles:putAttribute name="title" value="Login" />
        <tiles:putAttribute name="body" value="/WEB-INF/pages/login-body.jsp"/>
</tiles:insertDefinition>

What I would like to be able to do is when the tiles framework renders
the "header" component in the main definition, I would like to be able
to reference the value in the "title" attribute of this definition
inside of the header.jsp file.

With the old version of tiles, I simply went into my layout.jsp and did this:

<tiles:insertAttribute name="header">
  <tiles:putAttribute name="title"><tiles:getAsString
name="title"/></tiles:putAttribute>
</tiles:insertAttribute>

Then in header.jsp

<tiles:importAttribute/>
<tiles:getAsString name="title"/>

The problem is this isn't working with the 2.0.6 version of Tiles and
was curious what the proper way was to handle this so that I can set
title in the main definition but a fragment of the layout actually
uses it.

Reply via email to