I have created a layout JSP to use as a template for an abstract layout definition. I extend it with my concrete definition, for example (simplified):

<definition name="layout.tile" template="layout.jsp">
  <put-attribute name="headerTile" type="template" value="header.jsp" />
  <put-attribute name="menuTile" type="template" value="menu.jsp" />
</definition>
<definition name="categoryList.tile" extends="layout.tile">
  <put-attribute name="bodyContentTile" value="categoryList.jsp" />
  <put-attribute name="title" value="category.list.pageHeader" />
  <put-attribute name="subMenuTile" value="submenu.jsp" />
</definition>

The "title" attribute varies between concrete definitions. Unless I declare the "title" attribute again in the layout template, the header tile and header.jsp cannot see it, like this:


<tiles:importAttribute />
<body>
  <div id="container">
    <div id="header">
      <tiles:insertAttribute name="headerTile">
        <tiles:putAttribute name="title" value="${title}" />
      </tiles:insertAttribute>
    </div>
    <div id="content">
      <tiles:insertAttribute name="bodyContentTile"/>
    </div>
    <div id="subMenu">
      <div class="subMenu">
        <tiles:insertAttribute name="subMenuTile"/>
      </div>
    </div>
  </div>
</body>

Is this the right way to do it or is there a more elegant way?

I know that once this prototype goes into development, there will be many more attributes defined in the concrete definition but used in other tile templates. I would be glad to find out whether there is an automatic way of putting these attributes into the context of the pages where I need them?

I have looked hard at the possibility of 'nesting' the definitions, but that doesn't seem to be the solution, or at least it would be no more elegant than the above.

Thanks
Adam

Reply via email to