The issue that keeps coming up is the ability for jsps other than the
"page=" (template) jsp to have access to the attributes. John provided a
good technique using a second definition.  As to the definitions and the
template's ability to access attributes - you can add attributes to extended
definitions and then extend them.

I have an example app using that technique on my site:
http://www.calandva.com/holmansite/do/blog/blogging?date=20030711#094831

In this app I access the Tiles Context in an action and in a tag to modify
the attributes on the fly.  In the advanced pdf Cedric provides an example
of creating the number of columns in the body of a template on the fly.


  <definition name="home.pagedef" page="/template.jsp"
controllerUrl="/do/renderCrumb" >
          <put name="title"                     value="home.title" />
          <put name="header"            value="/web/includes/header.jsp" />
          <put name="index"             value="/web/pages/home/HomeIndex.jsp" />
          <put name="content"           value="/web/pages/home/HomeContent.jsp" />
          <put name="footer"            value="/web/includes/footer.jsp" />
          <put name="styleSheet"        value="web/styles/Grey_StyleSheet.css" />
          <put name="keywords"  value="home.keywords"/>
          <put name="crumbs"            value="/web/includes/crumb.jsp"/>
          <put name="crumbtitle1"       value="Home"/>
          <put name="crumblink1"        value="do/AutoForward?forward=home.pagedef"/>
          <put name="pagename"  value="home"/>
  </definition>

   <definition name="level2.pagedef" extends="home.pagedef">
          <put name="title"              value="level2.title" />
          <put name="index"            value="/web/pages/level2/Level2Index.jsp" />
          <put name="content"         value="/web/pages/level2/Level2Content.jsp"
/>
          <put name="keywords"      value="level2.keywords"/>
          <put name="crumbtitle2"    value="Level 2"/>
          <put name="crumblink2"    value="do/AutoForward?forward=level2.pagedef"/>
          <put name="pagename"    value="level2"/>
  </definition>

   <definition name="level3.pagedef" extends="level2.pagedef">
          <put name="title"              value="level3.title" />
          <put name="index"            value="/web/pages/level3/Level3Index.jsp" />
          <put name="content"        value="/web/pages/level3/Level3Content.jsp" />
          <put name="crumbtitle3"   value="Level 3"/>
          <put name="crumblink3"   value="do/AutoForward?forward=level3.pagedef"/>
          <put name="pagename"   value="level3"/>
  </definition>

When the level3.pagedef is used the template.jsp has access to all three
levels of crumbtitle values.  Some attributes are overridden and others are
added as the definitions are extended. Any attribute you add in the extended
path is available to the extended template.

Let me know if I am off base.

Cal
www.calandva.com

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
Behalf Of Hibbs, David
Sent: Monday, December 08, 2003 10:12 AM
To: 'Oliver Wulff'; [EMAIL PROTECTED]
Subject: RE: Tiles, Definition inheritence

        This is (IMHO) a classic issue with tiles.  The Tiles meaning of
'inheritance' isn't quite the same as in Java or other OO concepts.  Tiles
inherit values from their parents, and can override those values.  However,
adding new values is not supported.
        The only way [that I've found, anway] that you can support the
addition of new properties is to use the tiles importAttribute tag (see
http://jakarta.apache.org/struts/userGuide/struts-tiles.html#importAttribute
) in the main layout JSP, i.e. /layout/classicLayout.jsp, to pass the values
into a scope where they can be found by other tags such as <bean:write> and
use the values that way.

David Hibbs, ACS
Staff Programmer / Analyst
American National Insurance Company

> -----Original Message-----
> From: Oliver Wulff [mailto:[EMAIL PROTECTED]
> Sent: Monday, December 08, 2003 5:16 AM
> To: [EMAIL PROTECTED]
> Subject: Tiles, Definition inheritence
>
> Hi
>
> I'm quite new to Tiles and I've got the following problem:
>
> I've defined the following default definition:
> <definition name=".mainLayout" path="/layout/classicLayout.jsp">
>       <put name="title"  value="Berechtigung WEB with Tiles" />
>       <put name="header" value="/top_menu.jsp" />
>       <put name="menu"   value="/toc.jsp" />
>       <put name="footer" value="/footer.jsp" />
>       <put name="body"   value="/welcome.jsp" />
> </definition>
>
> The classicLayout.jsp hasn't been changed (Struts examples).
>
> Additionally, I've defined the following Definition:
> <definition name=".showOrgEinheit" extends=".mainLayout">
>       <put name="input" value="/getOrgEinheit.jsp" />
>       <put name="result" value="/showOrgEinheit.jsp" />
>       <put name="body" value="/layout/bodyTwoColumns.jsp" />
> </definition>
>
> The bodyTwoColumns looks like this:
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
>
> <table border="0" width="100%" cellspacing="5">
> <tr>
>   <td width="50%" align="left">
>     <tiles:insert attribute='input'/>
>   </td>
>   <td width="50%" align="left">
>     <tiles:insert attribute='result' />
>   </td>
> </tr>
> </table>
>
> My struts action forwards to the definition .showOrgEinheit
> but I get the
> following error:
> [ServletException in:/layout/bodyTwoColumns.jsp] Error - Tag
> Insert : No
> value found for attribute 'input'.'
>
> Can anybody help me, please? Thank you a lot.
>
> Cheers
> Oliver
>
>
>
>
>
>
> ******************* BITTE BEACHTEN *******************
> Diese Nachricht (wie auch allfällige Anhänge dazu) beinhaltet
> möglicherweise vertrauliche oder gesetzlich geschützte Daten oder
> Informationen. Zum Empfang derselben ist (sind) ausschliesslich die
> genannte(n) Person(en) bestimmt. Falls Sie diese Nachricht
> irrtümlicherweise erreicht hat, sind Sie höflich gebeten, diese unter
> Ausschluss jeder Reproduktion zu zerstören und die absendende Person
> umgehend zu benachrichtigen. Vielen Dank für Ihre Hilfe.
>
>

---------------------------------------------------------------------
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