You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Stefan Clos <ma...@gmx.net> on 2004/11/29 23:10:33 UTC
nested tiles
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: nested tiles
Posted by "David G. Friedman" <hu...@ix.netcom.com>.
Bill,
That was very nice of you. I'll have to add a complementary post about
using html tags with the name="SomeBeanInAScopeName" to access various beans
inside the various tiles. I posted about how to do that just this week.
Regards,
David
-----Original Message-----
From: Bill Keese [mailto:billk@tech.beacon-it.co.jp]
Sent: Thursday, December 02, 2004 12:43 AM
To: Struts Users Mailing List
Subject: Re: nested tiles
FYI, I went ahead and added a wiki page for this. Apparently this is
the first wiki page on general tile use (?)
http://wiki.apache.org/struts/StrutsDocTiles
(if you see any mistakes please correct them. or if anyone has any
other tips on tiles please add them.)
Bill
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested tiles
Posted by Bill Keese <bi...@tech.beacon-it.co.jp>.
FYI, I went ahead and added a wiki page for this. Apparently this is
the first wiki page on general tile use (?)
http://wiki.apache.org/struts/StrutsDocTiles
(if you see any mistakes please correct them. or if anyone has any
other tips on tiles please add them.)
Bill
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested tiles
Posted by Stefan Clos <ma...@gmx.net>.
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: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested tiles
Posted by Bill Keese <bi...@tech.beacon-it.co.jp>.
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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested tiles
Posted by Stefan Clos <ma...@gmx.net>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: nested tiles
Posted by Bill Keese <bi...@tech.beacon-it.co.jp>.
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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org