You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ed Dowgiallo <ed...@ptdprolog.net> on 2003/11/24 15:08:10 UTC

Inheritence and tile definitions III

My previous problems with title have been solved, but now I have an analogous problem with "content".  The idea of the definitions below is that I want to have a base.layout that determines the header and footer for all pages.  Base layout contains a "body" which can be replaced by different format JSPs, as in the form.layout and page.layout definitions.  login.form extends form.layout and passes it a "title" and "content".  Title is working fine, but I am getting an error saying that content can not be found in context.

I have added the following lines to baseLayout.jsp to attempt to resolve the issue.

    <tiles:insert attribute="body">
      <logic:present name="content"><tiles:put name="content" beanName="content" beanScope="tile"/></logic:present>
      <logic:present name="menu"><tiles:put name="menu" beanName="menu" beanScope="tile"/></logic:present>
    </tiles:insert>

The above did not work.  Any suggestions would be welcome.
Ed Dowgiallo

  <!-- ===================================================================== -->
  <!--                                                                       -->
  <!-- Base Layout                                                           -->
  <!--                                                                       -->
  <!-- ===================================================================== -->
  <definition name="base.layout" page="/layouts/baseLayout.jsp">
    <put name="system-short-name" value="TDL"/>
    <put name="title"             value="Base Page Layout"/>
    <put name="user-name"         value="Guest"/>
    <put name="header"  value="/common/header.jsp"/>
    <put name="body"    value="${body}"/>
    <put name="footer"  value="/common/footer.jsp"/>
  </definition>
  <!-- ===================================================================== -->
  <!--                                                                       -->
  <!-- Form Layout                                                           -->
  <!--                                                                       -->
  <!-- ===================================================================== -->
  <definition name="form.layout" extends="base.layout">
    <put name="title"   value="Form Page Layout"/>
    <put name="content" value="${content}"/>
    <put name="body"    value="/layouts/formLayout.jsp"/>
  </definition>
  <!-- ===================================================================== -->
  <!--                                                                       -->
  <!-- Page Layout                                                           -->
  <!--                                                                       -->
  <!-- ===================================================================== -->
  <definition name="page.layout" extends="base.layout">
    <put name="title"   value="Page Layout"/>
    <put name="menu"    value="${menu}"/>
    <put name="content" value="${content}"/>
    <put name="body"    value="/layouts/menuContentLayout.jsp"/>
  </definition>
  <!-- ===================================================================== -->
  <!--                                                                       -->
  <!-- Security Module Pages                                                 -->
  <!--                                                                       -->
  <!-- ===================================================================== -->
  <definition name="login.form" extends="form.layout">
    <put name="title"   value="Login Form"/>
    <put name="content" value="/security/login.jsp"/>
  </definition>

RE: Inheritence and tile definitions III

Posted by David Friedman <hu...@ix.netcom.com>.
Ed,

>From the previous tiles problem, it seems as though the base definition is
key and must list everything that needs to be 'global'.  So, it might fix
your problem if you make sure all elements are in it.  I.e. in
"base.layout", try including your content, which is defined everywhere
EXTENDING the base.layout but not IN the base.layout:

<put name="content" value="${content}"/>

Regards,
David
  -----Original Message-----
  From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
  Sent: Monday, November 24, 2003 9:08 AM
  To: Struts Users Mailing List
  Subject: Inheritence and tile definitions III


  My previous problems with title have been solved, but now I have an
analogous problem with "content".  The idea of the definitions below is that
I want to have a base.layout that determines the header and footer for all
pages.  Base layout contains a "body" which can be replaced by different
format JSPs, as in the form.layout and page.layout definitions.  login.form
extends form.layout and passes it a "title" and "content".  Title is working
fine, but I am getting an error saying that content can not be found in
context.

  I have added the following lines to baseLayout.jsp to attempt to resolve
the issue.

      <tiles:insert attribute="body">
        <logic:present name="content"><tiles:put name="content"
beanName="content" beanScope="tile"/></logic:present>
        <logic:present name="menu"><tiles:put name="menu" beanName="menu"
beanScope="tile"/></logic:present>
      </tiles:insert>

  The above did not work.  Any suggestions would be welcome.
  Ed Dowgiallo

    <!--
===================================================================== -->

        -->
    <!-- Base
       -->

        -->
    <!--
===================================================================== -->
    <definition name="base.layout" page="/layouts/baseLayout.jsp">
      <put name="system-short-name" value="TDL"/>
      <put name="title"             value="Base Page Layout"/>
      <put name="user-name"         value="Guest"/>
      <put name="header"  value="/common/header.jsp"/>
      <put name="body"    value="${body}"/>
      <put name="footer"  value="/common/footer.jsp"/>
    </definition>
    <!--
===================================================================== -->

        -->
    <!-- Form
       -->

        -->
    <!--
===================================================================== -->
    <definition name="form.layout" extends="base.layout">
      <put name="title"   value="Form Page Layout"/>
      <put name="content" value="${content}"/>
      <put name="body"    value="/layouts/formLayout.jsp"/>
    </definition>
    <!--
===================================================================== -->

        -->
    <!-- Page
       -->

        -->
    <!--
===================================================================== -->
    <definition name="page.layout" extends="base.layout">
      <put name="title"   value="Page Layout"/>
      <put name="menu"    value="${menu}"/>
      <put name="content" value="${content}"/>
      <put name="body"    value="/layouts/menuContentLayout.jsp"/>
    </definition>
    <!--
===================================================================== -->

        -->
    <!-- Security Module
      -->

        -->
    <!--
===================================================================== -->
    <definition name="login.form" extends="form.layout">
      <put name="title"   value="Login Form"/>
      <put name="content" value="/security/login.jsp"/>
    </definition>