Kevin,

To make an attribute available to a nested tile you need to pass it along
when you call the tile.  For example:

<tiles:insert attribute="bar">
        <tiles:put name="right"  beanName="right" beanScope="tile" />
        <tiles:put name="left" beanName="left" beanScope="tile" />
</tiles:insert>

Where beanName is the name of the attribute you want to pass and name is
what you want to pass it as and scope is tile context.  In your case, you
would also need to add a similar declaration in your .standardPage.header
tile since you need to pass it along twice.  Once you've done all that, you
would actually specify the tiles attribute values in the parent definition.
This can be very helpful in keeping all the attributes for a given "view" in
one definition instead of scattered all over your tiles-def.xml.

Tai

-----Original Message-----
From: Kevin Cramer [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 20, 2003 6:19 PM
To: Struts Users Mailing List
Subject: Re: Nesting tile definitions



I got it working.  It was a problem with something else.  I didn't
catch it.  It can be hard to find problems with the lack of debug
messages that come back from the server.

My next question was how do I use attributes from supertiles?  I want
to take a page and split it into tiles, one of which is the header.  I
also wanted to further divide the header into subtiles.  In particular
there is a part of a subtile in the header tile which can vary
depending on which page you are on.  I'm wondering what is the easiest
way to deal with it.

I'm doing all of this using the XML Tile definitions.  I put an
example below with just the relevant parts.  If I want page1 to use
one value for the "right" and page2 to use another value for "right"
how do I do that?  "right" is defined 2 levels down from the standard
page tile.  It would be nice to override it at the highest level.
Perhaps I am doing things wrong.  It seems wrong to define multiple
intermediate tiles for the different combinations.

<tiles-definitions>
  <definition name=".standardPage"
              path="/WEB-INF/common/layouts/standardLayout.jsp">
     <put name="title"       value="NO TITLE DEFINED" />
     <put name="header"      value=".standardPage.header" />
     <put name="footer"      value="/WEB-INF/common/footer.jsp" />
     <put name="content"     value="NO CONTENT DEFINED" />
  </definition>

  <definition name=".standardPage.header" 
              path="/WEB-INF/common/header.jsp">
    <put name="bar"  value=".standardPage.header.bar"/>
  </definition>

  <definition name=".standardPage.header.bar" 
              path="/WEB-INF/common/bar.jsp">
    <put name="right"  value="/WEB-INF/common/qsearch.jsp"/>
    <put name="left"  value="/WEB-INF/common/comp1.jsp"/>
  </definition>

  <definition name=".page1" 
              extends=".standardPage">
    <put name="title" value="Page 1"/>
    <put name="content" value="/WEB-INF/pages/page1.jsp"/>
  </definition>

  <definition name=".page2" 
              extends=".standardPage">
    <put name="title" value="Page 2"/>
    <put name="content" value="/WEB-INF/pages/page2.jsp"/>
  </definition>

</tiles-definitions>


Kevin

On Wed, Mar 19, 2003 at 05:07:04PM -0500, Tai Nguyen wrote:
> Kevin,
> 
> First if all, it is possible to use attributes from supertiles, but that's
> another issue.  The definitions you have posted look fine, so I would
guess
> that it's a problem with your header.jsp file.  Can you post that so we
can
> look at it, as well as the full error message you are getting?
> 
> Thanks,
> Tai
> 
> -----Original Message-----
> From: Kevin Cramer [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, March 19, 2003 4:43 PM
> To: [EMAIL PROTECTED]
> Subject: Nesting tile definitions
> 
> 
> 
> I am trying to have a tile definition include another definition but
> it doesn't seem to be working.  Can I do this and if so then how do I
> do it?
> 
> Here is an example of what I am trying to do.  I would like the header
> of a standard page to be another tile so I can further divide it into
> pieces.  However, when I try to create a definition that extends the
> .standardPage I get an error at the top of the page.  It just says
> that there has been a ServletException in
> /WEB-INF/common/layouts/header.jsp.  I understand that a tile cannot
> use attributes from subtiles or supertiles and I don't think that is
> the problem.
> 
> <tiles-definitions>
>   <definition name=".standardPage"
>               path="/WEB-INF/common/layouts/standardLayout.jsp">
>      <put name="title"       value="NO TITLE DEFINED" />
>      <put name="std_jscript" value="/WEB-INF/common/std-jscript.jsp" />
>      <put name="header"      value=".standardPage.header" />
>      <put name="footer"      value="/WEB-INF/common/footer.jsp" />
>      <put name="content"     value="NO CONTENT DEFINED" />
>   </definition>
> 
>   <definition name=".standardPage.header" 
>               path="/WEB-INF/common/layouts/header.jsp">
>    <put name="tagline.left"  value="/WEB-INF/common/qsearch.jsp"/>
>    <put name="tagline.right"  value="/WEB-INF/common/instBanner.jsp"/>
>  </definition>
> </tiles-definitions>
> 
> Thanks,
> Kevin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to