Under the old struts/tiles framework, we had a definition defined as:

<definition name=".mainLayout" path="/pages/layouts/defaultLayout.jsp">
  <put name="title" value="Please set your page title!"/>
  <put name="header" value="/pages/layouts/defaultHeader.jsp"/>
  <put name="body" value="" />
  <put name="footer" value="/pages/layouts/defaultFooter.jsp"/>
</definition>

Under Tiles 2; the definition remains nearly the same:

<definition name=".mainLayout"
template="/pages/layouts/defaultLayout.jsp">
    <put-attribute name="title" value="Please set your page title!"/>
    <put-attribute name="header"
value="/pages/layouts/defaultHeader.jsp"/>
    <put-attribute name="body" value="[[Empty Body]]" />
    <put-attribute name="footer"
value="/pages/layouts/defaultFooter.jsp" />
</definition>

So far this makes sense and works.  But under struts-tiles we were able
to create a single JSP that contained the following few lines:

<%@ taglib uri="http://struts.apache.org/tags-tiles"; prefix="tiles"  %>

<tiles:insert definition=".mainLayout">
  <tiles:put name="title">Test JSP Page</tiles:put>
  <tiles:put name="body" value="/pages/test-body.jsp"/>
</tiles:insert>

Our Tiles2 equivalent is now:

<%@ taglib uri="http://tiles.apache.org/tags-tiles"; prefix="tiles" %> 
<%@ taglib prefix="s" uri="/struts-tags" %>

<tiles:insertDefinition name=".mainLayout">
  <tiles:putAttribute name="title">Test JSP Page</tiles:putAttribute>
  <tiles:putAttribute name="body" value="/pages/test-body.jsp"/>
</tiles:insertDefinition>

But the problem seems to exist in the defaultLayout.jsp file itself.
The old struts-tiles one looked like:

<tiles:importAttribute/>
<tiles:insert attribute="header">
  <tiles:put name="title"><tiles:getAsString name="title"/></tiles:put>
</tiles:insert>
<tiles:insert attribute="body"/>
<tiles:insert attribute="footer"/>

The above allowed us to pass the "title" string defined in the test.jsp
into the defaultHeader.jsp page and display it in that JSP using the
tiles tag <tiles:getAsString name="title"/>.   

Unfortunately I am unable to reproduce this behavior with Tiles 2.  The
Tiles2 equilvalent of my layout is:

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

I get the error "Attribute with name = 'title' not found".  

This worked fine in struts-tiles so I'm confused as to what I need to do
in Tiles 2 so that I can define in my JSP which references the layout to
be used the page title and have it be passed from the main layout jsp
down into a particular included JSP inside the layout such as the header
where it should be used.

Thoughts ?


_______________________________________________________________
Chris Cranford
Programmer / Developer
SETECH Inc. & Companies
903 Industrial Drive, Murfreesboro, TN  37129
Phone: (615) 890-1755 Ext. 361, Fax: (615) 890-9057 Mobile: (704)
650-1042
Email: [EMAIL PROTECTED], [EMAIL PROTECTED]


Reply via email to