You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by st...@grattan.co.uk on 2004/03/17 13:53:50 UTC

Problem with Tiles

Hi

I am having a problem with a simple Tiles based site using the
classicLayout.

The problem is that the menu only appears on the first page - if I select a
link to another page the footer,body and copyright are rendered but the
menu is missing.

Here is the tiles-defs.xml ;

<?xml version="1.0" encoding="ISO-8859-1" ?>

 <!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
       "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">

<tiles-definitions>

   <definition name="doc.mainLayout" path="/layout/classicLayout.jsp">
        <put name="title"  value="Demo Application" />
        <put name="header" value="/common/header.jsp" />
        <put name="menu"   value="doc.menu.main" />
        <put name="body"   value="/common/defbody.jsp" />
        <put name="footer" value="/common/footer.jsp" />
  </definition>

  <definition name="doc.phoneusLayout" extends="doc.mainLayout">
        <put name="title"  value="Phone Us" />
        <put name="body"   value="/jsp/phoneustile.jsp" />
  </definition>

  <definition name="doc.menu.main" path="/layouts/vboxLayout.jsp" >
    <putList name="list" >
      <add value="common.menu.clerk" />
      <add value="common.menu.supervisor"/>
      <add value="common.menu.manager"/>
      <add value="common.menu.help"/>
    </putList>
  </definition>

  <definition name="common.menu.clerk" path="/layouts/menu.jsp" role=
"clerk">
    <put name="title" value="Clerk Functions" />
    <putList name="items" >
      <item value="Function 1"  link="/jsp/F1preTile.jsp" />
    </putList>
  </definition>

  <definition name="common.menu.supervisor" path="/layouts/menu.jsp" role=
"supervisor" >
    <put name="title" value="Supervisor Functions" />
    <putList name="items" >
      <item value="Function 2"  link="/jsp/F2preTile.jsp" />
    </putList>
  </definition>

  <definition name="common.menu.manager" path="/layouts/menu.jsp" role=
"manager" >
    <put name="title" value="Manager Functions" />
    <putList name="items" >
      <item value="Function 3"  link="/jsp/F3preTile.jsp" />
    </putList>
  </definition>

  <definition name="common.menu.help" path="/layouts/menu.jsp"  role=
"clerk">
    <put name="title" value="Help" />
    <putList name="items" >
      <item value="Email us"     link="/jsp/emailus.jsp" />
      <item value="Phone us"     link="/jsp/phoneus.jsp" />
    </putList>
  </definition>

</tiles-definitions>

As can be seen, the menu will display different sections based on which
roles the user has defined. This part works OK on the initial screen, but
as soon as I select a different page (e.g. phoneus.jsp), nothing is
displayed where the menu should be.

phoneus.jsp is as follows ;

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<tiles:insert definition="doc.phoneusLayout" flush="true" />

and /jsp/phoneustile.jsp is as below ;

<br><br>
<h4> Phone us at 01274 123456</h4>

In web.xml I define the welcome page as index.jsp, which is as follows ;

<%@ page language="java" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>

<tiles:insert definition="doc.mainLayout" flush="true" />

This page does display a menu.

I would be grateful for any help anyone can give.



Any opinions expressed in this Email are strictly the responsibility of the
author, and not those of Otto-UK.



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org