I understand how to make the example work, but the point of my example
was that tile attributes should be "recursively accessible" so that I
don't have to clutter up intermediary files with code that only serves
to export attributes.

You only have to expand the example a little bit to make your solution
a even more unwieldy.

Say you wanted to parameterize the content somehow.  Say you have two
types of training:  "light" and "heavy".  You might be tempted to
break training.jsp out into two files, training-light.jsp and
training-heavy.jsp, and end up with two definitions:

  <definition name="training.light" path="/layout.jsp">
    <put name="content" value="/training-light.jsp"/>
    <put name="title"   value="Training"/>
  </definition>
  <definition name="training.heavy" path="/layout.jsp">
    <put name="content" value="/training-heavy.jsp"/>
    <put name="title"   value="Training"/>
  </definition>

The problem with that solution is that those two files happen to
differ by only one word.  All of their code is exactly alike except
one contains the word "light" and the other has the word "heavy".
Regardless of how much they differ, the point is that they have
something in common and could therefore benefit by sharing it.  What I
would like to be able to do with Tiles is something like this:

  <definition name="training.light" path="/layout.jsp">
    <put name="content" value="/training.jsp"/>
    <put name="title"   value="Training"/>
    <put name="type"    value="light"/>
  </definition>
  <definition name="training.heavy" extends="training.light">
    <put name="type"    value="heavy"/>
  </definition>

The above is legal Tiles syntax, and it saves me from having to create
two extra almost-identical files, but unfortunately, it won't
work. :-(

-- Jim

"Robert D. Morse" <[EMAIL PROTECTED]> writes:

> You're correct that it won't find "title".  layout.jsp needs to store it so
> it can be accessed by header (e.g., session.setAttribute()).
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of Jim
> Crossley
> Sent: Tuesday, February 19, 2002 12:39 PM
> To: Struts Users Mailing List
> Cc: James CE Johnson
> Subject: Why don't tiles "cascade"?
> 
> 
> Apparently it's not possible to access attributes of any tiles other
> than your immediate "parent".  IMHO, this restricts my ability to
> partition my presentation code into simple, reusable chunks.
> 
> Here's a semi-practical example.
> 
> Consider this snippet from a definitions file...
> 
>   <definition name="training" path="/layout.jsp">
>     <put name="content" value="/training.jsp"/>
>     <put name="title"   value="Training"/>
>   </definition>
> 
> layout.jsp
> -- CUT --
> <tiles:insert path="/header.jsp"/>
> <tiles:insert attribute="content"/>
> <tiles:insert path="/footer.jsp"/>
> -- CUT --
> 
> header.jsp
> -- CUT --
> <html>
>   <head>
>     <title><tiles:getAsString name="title"/></title>
>   </head>
>   <body>
> -- CUT --
> 
> footer.jsp
> -- CUT --
>   </body>
> </html>
> -- CUT --
> 
> The above example, as simple as it is, won't work, because header.jsp
> can't find the attribute named "title".
> 
> Have I completely misunderstood the intent behind Tiles, or is it
> simply not quite ready for prime time?  Is there a better (simpler)
> approach than the one taken in the above example?
> 
> -- Jim
> 
> --
> To unsubscribe, e-mail:
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
> <mailto:[EMAIL PROTECTED]>
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

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

Reply via email to