You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by De...@siriuscom.com on 2003/10/27 21:46:17 UTC
nested tiles in struts
I can't seem to find any good examples of how to do this. I would like to
have a nested tile inside of my body.jsp. For example I have a definition.
<definition name="tiles.mainLayout" path="/WEB-INF/jsp/common/layout.jsp">
<put name="title" value="Tiles Blank Site" />
<put name="header" value="/WEB-INF/jsp/common/header.jsp" />
<put name="menu" value="/WEB-INF/jsp/common/menu.jsp" />
<put name="body" value="/WEB-INF/jsp/common/body.jsp" />
</definition>
And typically I override it as such
<definition name="tiles.One" extends="tiles.mainLayout">
<put name="title" value="Different Title" />
<put name="body" value="/WEB-INF/jsp/differentBody.jsp" />
</definition>
But what if I would like in some situations to have an include in the
"body". Say I would like to use One Jsp page but would like to, from the
Struts-config, call that same page but have different forms inserted
depending on the situations. So, I would have possibly two definitions like
this.
<definition name="tiles.One" extends="tiles.mainLayout">
<put name="title" value="Different Title" />
<put name="body" value="/WEB-INF/jsp/differentBody.jsp" />
<put name="form" value="/WEB-INF/jsp/formOne.jsp" />
</definition>
<definition name="tiles.Two" extends="tiles.mainLayout">
<put name="title" value="Different Title" />
<put name="body" value="/WEB-INF/jsp/differentBody.jsp" />
<put name="form" value="/WEB-INF/jsp/formTwo.jsp" />
</definition>
My assumption (thus far wrong) was that I could insert the "form" inside my
differentBody.jsp. But when I run it, my differentBody.jsp fails claiming
it can't find "form". Is this because I don't have "form" defined in my
mainLayout? I have tried to define it there even going so far as to have
the body use a "put" with the layout.jsp.
Am I way off track here for something that seems to me a simple task? Is
this even the right place to post this question?
Thanks.
Derwyn
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: nested tiles in struts
Posted by Frank Rizzo <et...@yahoo.com>.
I think that this will work for you. here is a nested tile in the body. some of my pages require a bordered box around the content, so the bordered box is a tile called .borderedContent. Shown below is a relevant excerpt from tiles-defs.xml, then the borderedcontent.jsp, and then the about page, which uses the basic layout with a nested tile.
<definition name=".basicLayout" path="/tiles/layouts/basiclayout.jsp">
<put name="title" value="Wxyz" />
<put name="standardheader" value="/tiles/standardheader.jsp" />
<put name="header" value="/tiles/pageheader.jsp" />
<put name="body" value=".overRideMe" />
<put name="footer" value="/tiles/footer.jsp" />
</definition>
<definition name=".borderedContent" path="/tiles/borderedcontent.jsp">
<put name="heading" value="" />
<put name="body" value=".overRideMe" />
</definition>
<%@ taglib uri="/tags/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/tags/struts-tiles.tld" prefix="tiles" %>
<table border="0" cellpadding="0" cellspacing="0" style="margin-bottom:10px">
<tr>
<td height="16px" valign="top" align="left" width="16px"><img src="/image/pod_corner_ul.gif" alt="" width="16" height="16" border="0"></td>
<td align="left" height="16px" nowrap background="/image/pod_side_top.gif"><img src="/image/null.gif" alt="" width="16" height="16" border="0"></td>
<td height="16px" valign="top" align="right" width="16px"><img src="/image/pod_corner_ur.gif" alt="" width="16" height="16" border="0"></td>
</tr>
<tiles:useAttribute name="heading" />
<logic:notEmpty name="heading" >
<tr>
<td colspan="3" class="podHeader">
<!-- POD HEADER -->
<bean:write name="heading" />
<!-- END POD HEADER -->
</td>
</tr>
</logic:notEmpty>
<tr>
<td valign="top" background="/image/pod_side_left.gif"><img src="/image/null.gif" alt="" width="16" height="16" border="0"></td>
<td valign="top">
<div style="margin-top:10px">
<tiles:get name="body" />
</div>
</td>
<td valign="top" background="/image/pod_side_right.gif"><img src="/image/null.gif" alt="" width="16" height="16" border="0"></td>
</td>
</tr>
<tr>
<td height="16px" valign="top" align="left" width="16px"><img src="/image/pod_corner_bl.gif" alt="" width="16" height="16" border="0"></td>
<td align="left" height="16px" nowrap background="/image/pod_side_bottom.gif"> </td>
<td height="16px" valign="top" align="right" width="16px"><img src="/image/pod_corner_br.gif" alt="" width="16" height="16" border="0"></td>
</tr>
</table>
<%@ taglib uri="/tags/w.tld" prefix="w" %>
<%@ taglib uri="/tags/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/tags/struts-html.tld" prefix="html" %>
<%@ taglib uri="/tags/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/tags/struts-tiles.tld" prefix="tiles" %>
<div class="pHead">About Us</div><br>
<div style="margin-left:55px;width:70%">
<tiles:insert definition=".borderedContent">
<tiles:put name="body" type="string" >
<div class="btext">
<div class="ahead">Wxyz - Superstar</div>
blah, blah, blah.<br><br>
<div class="ahead">Who We Are</div>
At Wxyz, we rock your world and build your business.<br><br>
</tiles:put>
</tiles:insert>
</div>
Derwyn.Harris@siriuscom.com wrote:
I can't seem to find any good examples of how to do this. I would like to
have a nested tile inside of my body.jsp. For example I have a definition.
And typically I override it as such
But what if I would like in some situations to have an include in the
"body". Say I would like to use One Jsp page but would like to, from the
Struts-config, call that same page but have different forms inserted
depending on the situations. So, I would have possibly two definitions like
this.
My assumption (thus far wrong) was that I could insert the "form" inside my
differentBody.jsp. But when I run it, my differentBody.jsp fails claiming
it can't find "form". Is this because I don't have "form" defined in my
mainLayout? I have tried to define it there even going so far as to have
the body use a "put" with the layout.jsp.
Am I way off track here for something that seems to me a simple task? Is
this even the right place to post this question?
Thanks.
Derwyn
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
---------------------------------
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears