Yes it works. Here is my working configuration. Thank you very much.
tiles-def.xml:
-------------------
<definition name="defaultLayout" template="/WEB-INF/pgs/common/layout/layout.jsp">
<put name="header" value="/WEB-INF/pgs/common/layout/header.jsp" />
<put name="navigation" value="/WEB-INF/pgs/common/layout/navigation/default_nav.jsp" />
<put name="bodyFrame" value="/WEB-INF/pgs/common/layout/bodyFrame.jsp" />
</definition>
<definition name="startpage" extends="defaultLayout"> <put name="body" value="/startpage.jsp" /> </definition>
layout.jsp
------------------
<tiles:insert attribute="bodyFrame" >
<tiles:put name="bodypage" beanName="body" /> <!-- it works without specify type="page" here -->
<!-- If you use beanScope="tile", beanScope="component", beanScope="template"
or do not using attribute beanScope doenīt matter -->
</tiles:insert>
Bill Keese schrieb:
Yeah, I also wish there was more documentation on this.
I think I found the flaw in your original design. In layout.jsp you want to take the "body" attribute defined in tiles-def.xml and pass it on to bodyFrame.jsp as "bodypage". So you need to use beanName, right?
tiles-def.xml:
-------------------
<definition name="startpage" extends="layout.jsp">
<put name="bodyFrame" value="/WEB-INF/pgs/common/layout/bodyFrame.jsp" />
<put name="body" value="/WEB-INF/pgs/common/layout/startpage.jsp" />
</definition>
layout.jsp
------------------
<tiles:insert attribute="bodyFrame" >
<tiles:put name="bodypage" type="page" beanName="body" beanScope="tile"/> <!-- define "bodypage" based on value of "body" -->
</tiles:insert>
bodyFrame.jsp -------------------- <tiles:insert name="bodypage" />
Does that work for you?
Stefan Clos wrote:
thanks Bill,
your way to make nested tiles works fine. (After i changed "extends" to "template" in the second definition).
It has the advantage that the jspīs are smaller and easier to understand, but at the cost you
need 2 definitions for each page. If you are only use one BodyFrame, you need a little more code i think.
I hope there are coming a better documentation about nested tiles with some best practics in future.
Stefan
Bill Keese schrieb:
Interesting. I'm not sure why your code doesn't work. Maybe the value attribute in <put name="body" value="/startpage.jsp" /> should be /WEB-INF/pgs/startpage.jsp.
Anyway, I haven't done nested tiles in the same way as you do. This is how I do nested tiles. Maybe someone can comment on which way is better.
<definition name="defaultLayout" template="/WEB-INF/pgs/common/layout/layout.jsp">
<put name="header" value="/WEB-INF/pgs/common/layout/header.jsp" />
<put name="navigation" value="/WEB-INF/pgs/common/layout/navigation/default_nav.jsp" />
<!-- definitions based on this layout must define "body" -->
</definition>
<!-- first define the inner tile -->
<definition name="startpage.body" extends="/WEB-INF/pgs/common/layout/bodyFrame.jsp">
<put name="bodypage" value="/startpage.jsp" />
</definition>
<!-- then define the whole page by referencing the inner tile --> <definition name="startpage" extends="defaultLayout"> <put name="body" value="startpage.body" type="definition"/> </definition>
Bill
Stefan Clos wrote:
hi,
i have a problem with nested tiles. I found not much about it in the struts doc.
the problem is that it not displays the correct body page.I get a directory listing there.
At the definition startpage i have the value "/startpage.jsp"
This should be displayed at my page. But it doesnīt :(
I am using Struts 1.2 with Tomcat 5.
Thank you all very much for your answers, a link to helpful documentation in the internet,
is also welcome.
Stefan Clos
tiles-def.xml:
-------------------
<definition name="defaultLayout" template="/WEB-INF/pgs/common/layout/layout.jsp">
<put name="header" value="/WEB-INF/pgs/common/layout/header.jsp" />
<put name="navigation" value="/WEB-INF/pgs/common/layout/navigation/default_nav.jsp" />
<put name="bodyFrame" value="/WEB-INF/pgs/common/layout/bodyFrame.jsp" />
</definition>
<definition name="startpage" extends="defaultLayout">
<put name="body" value="/startpage.jsp" /> <--- put the page here
</definition>
layout.jsp ------------------ <%-- Header incl. <body> --%> <tiles:insert attribute="header" />
<%-- complete navigation --%> <tiles:insert attribute="navigation" />
<%-- Rest of the Page (everything after the navigation) --%>
<tiles:insert attribute="bodyFrame" >
<tiles:put name="body" type="page" direct="false" /> <---- put it here
</tiles:insert>
bodyFrame.jsp
--------------------
<div id="backgrounddiv">
<div id="header">
<h1>Community</h1>
</div>
<div id="globalcontainer">
<tiles:insert name="bodypage" /> <------------- should be at this point, but tomcat show me a directory listing there, funny but not what i want
</div>
</div>
</body>
</html>
-------------------
--------------------------------------------------------------------- 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]