Hello list, I'm having a small problem with tiles at the moment 
and I don't know if what I'm trying to do is correct etc. Maybe 
the collective wisdom and shed some light on what I'm doing 
wrong...

I've got a default definition, say for example:

<%@ taglib uri="http://struts.apache.org/tags-tiles-el"; prefix="tiles" %>
<html>
<head>
  <title><tiles:getAsString name="title" /></title>
</head>
<body>
<tiles:insert attribute="body" />
</body>
</html>

<definition name=".default" page="/tiles/default.jsp" />

I can then put other tiles into this definition to extend the 
look and feel, thus I've got a further two definitions, both
for a graphical frame, one with and the other without a menu.

<%@ taglib uri="http://struts.apache.org/tags-tiles-el"; prefix="tiles" %>
<table class="frame" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td><img src="..." /></td>
  </tr>
  <tr>
    <td><img src="..." /></td>
    <td rowspan="2" valign="top">
      <tiles:insert attribute="frameBody" />
    </td>
    <td><img src="..." /></td>
  </tr>
  <tr>
    <td><img src="..." width="30" height="10" alt="" /></td>
    <td><img src="..." width="930" height="10" alt="" /></td>
    <td><img src="..." width="30" height="10" alt="" /></td>
  </tr>
</table>

<definition name=".frameNoMenu" extends=".default">
  <put name="body" value="/tiles/frame-no-menu.jsp" />
</definition>

However, to get the frameBody bit to display I have to pass
it through in the original default.jsp file thus:

<tiles:insert attribute="body">
  <tiles:useAttribute id="frameBody" name="frameBody" ignore="true" 
scope="page" />
  <c:if test="${not empty pageScope.frameBody}">
    <tiles:put name="frameBody" value="${pageScope.frameBody}" type="template" 
/>
  </c:if>
</tiles:insert>

Otherwise I get an exception telling me that nothing could be 
found for attribute frameBody.

Now I want to also create a poage that has the frame and two column
so I created another definition to handle this:

<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles-el"; prefix="tiles" %>
<table>
  <colgroup>
    <tiles:importAttribute name="leftWidth" ignore="true" scope="page" />
    <c:choose>
      <c:when test="${not empty pageScope.leftWidth}">
        <col id="left" style="width: <tiles:getAsString name="leftWidth" />;" />
      </c:when>
      <c:otherwise>
        <col id="left" />
      </c:otherwise>
    </c:choose>
    
    <tiles:importAttribute name="rightWidth" ignore="true" scope="page" />
    <c:choose>
      <c:when test="${not empty pageScope.rightWidth}">
        <col id="right" style="width: <tiles:getAsString name="rightWidth" />;" 
/>
      </c:when>
      <c:otherwise>
        <col id="right" />
      </c:otherwise>
    </c:choose>
  </colgroup>
  <tbody>
    <tr>
      <td style="vertical-align: top; padding-right: 4px; padding-top: 5px;">
        <tiles:insert attribute="left" />
      </td>
      <td style="vertical-align: top; padding-left: 4px; padding-top: 5px;">
        <tiles:insert attribute="right" ignore="true" />
      </td>
    </tr>
  </tbody>  
</table>

<definition name=".variableLeftRightSplit" extends=".frameMenu">
  <put name="frameBody" value="/tiles/left-right-split.jsp" />
</definition>
  
<definition name=".40-60split" extends=".variableLeftRightSplit">
  <put name="leftWidth"  value="40%" />
  <put name="rightWidth" value="60%" />
</definition>

So I should now have a page that's got the frame and has two columns
one at 40% and the other at 60%. Except I don't. I'm padssing through 
all the attributes - frameBody, left, leftWidth, right and rightWidth
on both the default.jsp and the frame-no-menu.jsp. 

When I specify a page that uses the .frameMenu definition it works 
okay and displays my page. when I try and use the .40-60split 
definition I get a page that displays my frame, but nothing in the 
frameBody.

I've output the frameBody attributre and I have confirmed that it 
contains what I expect, i.e. /tiles/left-right-split.jsp, but it's 
just not being displayed. 

Am I totally barking up the wrong tree with this? Can you build pages 
with tiles like this, or are you supposed to o it via multiple 
definitions like:

<definition name=".default" page="/tiles/default.jsp" />

<definition name=".logon" extends=".default">
  <put name="title" value="This is a test..." />
  <put name="body" value=".logonBody" />
</definition>

<definition name=".logon" extends="/tiles/frame-no-menu.jsp">
  <put name="frameBody" value="/public/logon-body.jsp" />
</definition>

Any help anyone can give me with this would be much appreciated.

Cheers,

-- 
Bob Arnott



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to