You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Andrew Martin <An...@ictu.nl> on 2006/10/11 16:05:35 UTC
Tiles: attribute values within nested JSP's!
Hi,
I have a problem with nested tiles. I can't seem to be able to read the value of a attribute in nested JSP's!
having looked through this list it appears that I am not alone, but I have yet to find a working solution.
Maybe there isn't one! In which case I ask myself whats the added benifit of utilising tiles in the first place.
Basically I defined my tile structure within the tiles-def.xml, as follows;
<tiles-definitions>
<!-- Parent Base Tiles Definition -->
<definition name="base.definition" path="/WEB-INF/jsp/siteLayout.jsp" />
<!-- The following definitions split the contents into base tiles -->
<definition extends="base.definition" name="sub1.definition">
<put name="header" value="/WEB-INF/jsp/header1.jsp"/>
<put name="menu" value="/WEB-INF/jsp/menu1.jsp"/>
</definition>
<definition extends="base.definition" name="sub2.definition">
<put name="header" value="/WEB-INF/jsp/header2.jsp"/>
<put name="menu" value="/WEB-INF/jsp/menu2.jsp"/>
</definition>
<!-- Finally I extend the sub definitions with content pages -->
<definition extends="sub1.definition" name="page.overview">
<put name="title" value="Page Title 1"/>
<put name="body" value="/WEB-INF/jsp/page1.jsp"/>
</definition>
<definition extends="sub2.definition" name="page.overview">
<put name="title" value="Page Title 2"/>
<put name="body" value="/WEB-INF/jsp/page2.jsp"/>
</definition>
<definition extends="sub2.definition" name="page.overview">
<put name="title" value="Page Title 3"/>
<put name="body" value="/WEB-INF/jsp/page3.jsp"/>
<put name="content" value="/WEB-INF/jsp/subcontent3.jsp"/>
</definition>
</tiles-definitions>
In my siteLayout.jsp I define the look and feel and place the insert/get attributes tages as follows;
<tiles:getAsString name="title" />
<tiles:insert attribute="menu" />
<tiles:insert attribute="body" />
This works fine as all attributes can be seen and inserted at this level.
Within the page3.jsp which extends sub2.definition I also want to insert the subcontent3.jsp page as follows;
<tiles:insert attribute="content" />
Which throws an except "Error - Tag Insert : No value found for attribute 'content'" or
attribute 'content'not found in context"
I have tried utilizing the <tiles:useAttribute ... scope="request"/> and importAttribut within the sitelayout.jsp (and within all relating pages) but that doesn't seem to help! I have read on numerous occasions that the tiles are defined within their own context, but how can they be read / utilized in other nested tiles. If this is possible it would enable me to place a lot of the navigation / context logic in the XML definitions!
Thanks in advance for the help.
Andrew
Re: Tiles: attribute values within nested JSP's!
Posted by Antonio Petrelli <ap...@apache.org>.
Andrew Martin ha scritto:
> <!-- Finally I extend the sub definitions with content pages -->
>
> <definition extends="sub1.definition" name="page.overview">
> <put name="title" value="Page Title 1"/>
> <put name="body" value="/WEB-INF/jsp/page1.jsp"/>
> </definition>
>
> <definition extends="sub2.definition" name="page.overview">
> <put name="title" value="Page Title 2"/>
> <put name="body" value="/WEB-INF/jsp/page2.jsp"/>
> </definition>
>
> <definition extends="sub2.definition" name="page.overview">
> <put name="title" value="Page Title 3"/>
> <put name="body" value="/WEB-INF/jsp/page3.jsp"/>
> <put name="content" value="/WEB-INF/jsp/subcontent3.jsp"/>
> </definition>
>
Three definitions with the same name???
This is a bug, my friend :-)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org