In Tiles, you can put attributes only into layout pages. In short terms
you should modify your tiles-defs.xml this way:

  <definition name="header.with.title" path="/header.jsp">
    <put name="pageTitle" value="Welcome" />
  </definition>

  <definition name="base.definition" path="/layout.jsp">
    <put name="leftNav" value="/leftNav.jsp" />
    <put name="footer" value="/footer.jsp" />
  </definition>

  <definition name="page.home" extends="base.definition">
    <put name="header" value="header.with.title" />
    <put name="body" value="/home.jsp" />
  </definition>

Ciao
Antonio Petrelli

Neil Aggarwal wrote:

>Hello:
>
>I am a newbie to struts and am trying to get a handle on
>tiles:getAsString tag.  I am having a problem in
>that is complains that the attribute I am trying to
>get does not exist.
>
>Here is what I have in my tiles-defs.xml:
>
><tiles-definitions>
>  <!-- Base Tiles Definition -->
>  <definition name="base.definition" path="/layout.jsp">
>    <put name="leftNav" value="/leftNav.jsp" />
>    <put name="header" value="/header.jsp" />
>    <put name="footer" value="/footer.jsp" />
>  </definition>
>
>  <!-- Tiles definition of home page -->
>  <definition name="page.home" extends="base.definition">
>    <put name="pageTitle" value="Welcome" />
>    <put name="body" value="/home.jsp" />
>  </definition>
></tiles-definitions>
>
>I have an index.jsp that loads the page.home defintion:
><[EMAIL PROTECTED] uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
><tiles:insert definition="page.home" />
>
>Here is the layout.jsp (trimmed):
><[EMAIL PROTECTED] language="java" %>
><[EMAIL PROTECTED] file="/imports.jsp" %>
><[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-html"; 
>prefix="html"
%>
><[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-tiles";
prefix="tiles"
>%>
>
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
>
><html:html locale="true">
>  <body background="/images/pageBackground.gif">
>    <table border="0" width="100%" cellspacing="0" cellpadding="0">
>      <tr>
>        <td align="right" valign="top" width="150"><tiles:insert
>attribute="leftNav" /></td>
>        <td valign="top"><html:img border="0" height="700"
>src="/images/transparent1x1.gif" width="10" /></td>
>        <td align="left" valign="top"><tiles:insert attribute="header"
>/><tiles:insert attribute="body" /><tiles:insert attribute="footer"
/></td>
>      </tr>
>    </table>
>  </body>
></html:html>
>
>Here is the header.jsp (trimmed):
><[EMAIL PROTECTED] language="java" %>
><[EMAIL PROTECTED] file="/imports.jsp" %>
><[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-html"; 
>prefix="html"
%>
><[EMAIL PROTECTED] uri="http://jakarta.apache.org/struts/tags-tiles";
prefix="tiles"
>%>
>
><table>
>  <tr>
>    <td class="pageTitle"><tiles:getAsString name="pageTitle" /></td>
>  </tr>
>
>When I try to load the page (You can see what I have at
>http://dev.crcbusinessservices.com/crcgroup/index.jsp)
>
>I get this error in the tomcat log:
>SEVERE: ServletException in '/layout.jsp':
>ServletException in '/header.jsp':
>Error - tag.getAsString :
>attribute 'pageTitle' not found in context. Check tag syntax
>
>Any ideas?
>
>Thanks,
>       Neil
>
>--
>Neil Aggarwal, JAMM Consulting, (972)612-6056, www.JAMMConsulting.com
>FREE! Valuable info on how your business can reduce operating costs by
>17% or more in 6 months or less! http://newsletter.JAMMConsulting.com
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>



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

Reply via email to