Nils Liebelt wrote:
> Hi all,
> 
> Let's say I got a typical tile main layout definition:
> 
>     <definition name=".mainLayout"
>         path="/common/mainLayout.jsp"> <put name="header"
>         value="/common/header.jsp" /> <put name="content"
>         value="sample" type="string"/> <put name="footer"
>     value="/common/footer.jsp" /> </definition>
> 
> Now the content has to split into 2 panes. But not
> always. So I would like to have definition who looks like
> this: 
> 
>     <definition name=".splitLayout.SetupHome"
>         extends=".mainLayout"> <put name="content"
>         value=".splitPane" type="definition"/> <put
>         name="content.menu" value="lalelupo"/> <put
>     name="content.body" value="la le luuuuuuuu"
> type="string"/> </definition> 
> 
> The syntax is not right but it explains what I want. Is
> it possible some how. I can only access "menu" and "body"
> as beans. All other tiles insert tags are useless.

I have achived this by doing the following (I don't claim this is 
the best or correct way to do it, it's just worked for me).

In my definitions file I have something like the following -

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

<definition name=".leftRightSplit" extends=".default"> 
  <put name="body" value="/tiles/left-right-split.jsp" />
</definition>

<definition name=".split40-60" extends=".leftRightSplit"> 
  <put name="leftWidth"  value="40%" />
  <put name="rightWidth" value="60%" />
</definition>

<definition name=".page" extends=".split40-60"> 
  <put name="title" value="page.title" />
  <put name="left"  value="/private/page-left.jsp" />
</definition>

<definition name=".pageResults" extends=".page"> 
  <put name="right"  value="/private/page-right.jsp" />
</definition>

Then I have something like the following for teh two tiles JSP files:

default.jsp ----------

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-bean-el"; prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html-el"; prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles-el"; prefix="tiles" %>

<html:html xhtml="true" lang="true">
<head>
  <title>
    <tiles:useAttribute id="title" name="title" scope="page" />
    <bean:message key="${pageScope.title}" />
  </title>
</head>
<body>

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

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

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

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

</body>
</html:html>

left-right-split.jsp ----------

<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"; prefix="c" %>
<%@ taglib uri="http://struts.apache.org/tags-html-el"; prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles-el"; prefix="tiles" %>

<html:xhtml />

<table class="leftRightSplit">
  <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 class="leftColumn">
        <%-- Left part goes here... --%>
        <tiles:insert attribute="left" />
      </td>
      <td class="rightColumn">
        <%-- Right part goes here... --%>
        <tiles:insert attribute="right" ignore="true" />
      </td>
    </tr>
  </tbody>  
</table>

page-left.jsp and page-right.jsp are just the content of the page you want 
to display.

I hope this helps.

Cheers,

-- 
Bob Arnott



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

Reply via email to