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/23 15:18:51 UTC

Inheritance in tile definitions II

My thanks to all those who offered suggestions for my first problem.

Let's say that I have the following in a definitions file:

  <!-- ===================================================================== -->
  <!--                                                                       -->
  <!-- Form Layout                                                           -->
  <!--                                                                       -->
  <!-- ===================================================================== -->
  <definition name="form.layout" page="/layouts/formLayout.jsp">
    <put name="system-short-name" value="TDL"/>
    <put name="user-name" value="Guest"/>
    <put name="title"   value="Form Page Layout"/>
    <put name="header"  value="/common/header.jsp"/>
    <put name="content" value="${content}"/>
    <put name="footer"  value="/common/footer.jsp"/>
    <put name="debug"   value="/debug.jsp"/>
  </definition>
  <definition name="login.form" extends="form.layout">
    <put name="title"   value="Login Form"/>
    <put name="content" value="/security/login.jsp"/>
  </definition>

When I access title using GetAsString from formLayout.jsp, I get the expected value of Login Form.

How do I access the value of title from header.jsp?

Thank you,
Ed

Re: Inheritance in tile definitions II

Posted by Ed Dowgiallo <ed...@ptdprolog.net>.
Thank you very much David.  That solved the problem.

Ed
----- Original Message -----
From: "David Friedman" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, November 24, 2003 3:23 AM
Subject: RE: Inheritance in tile definitions II


> Ed,
>
> The list archives describe this problem. I didn't understand it until I
> tested it.
>
> Inside the main definition, /layouts/formLayout.jsp, you'd normally have a
> segment like this:
>
> <tiles:get name="header"/>
>
> Instead, they say to pass any tile-defined attribute, you must use an
insert
> and put in the place where you include that "included" page such as:
>
> <tiles:insert attribute="header">
> <tiles:put name="title" beanName="title" beanScope="tile" />
> </tiles:insert>
>
> This is odd but did indeed work for me a second ago to show my title in my
> header.jsp using <tile:getAsString name="title" />
>
> It came from here:
> http://www.mail-archive.com/struts-user@jakarta.apache.org/msg61368.html
>
> Regards,
> David
>
> -----Original Message-----
> From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
> Sent: Sunday, November 23, 2003 12:32 PM
> To: Struts Users Mailing List
> Subject: Re: Inheritance in tile definitions II
>
>
> When I simply place a getAsString in the header.jsp, I get an error
message
> which says that title can not be found in the context.  I get the same for
> useAttribute.
>
> Ed
> ----- Original Message -----
> From: "David Friedman" <hu...@ix.netcom.com>
> To: "Struts Users Mailing List" <st...@jakarta.apache.org>
> Sent: Sunday, November 23, 2003 12:22 PM
> Subject: RE: Inheritance in tile definitions II
>
>
> > Ed,
> >
> > The tile definition is initialized before the pages/jsp's/actions are
> > called.  You can therefore access any name in any component as long as
> that
> > component is tiles aware.  In the case of your JSP's, juse use the tiles
> > taglib and do what you did in header.jsp to obtain the title (a
> getAsString,
> > if I recall correctly).  In the case of an action, you'd need to
subclass
> > the TilesAction to manipulate it directly (i.e. to set the title from
> within
> > the Action directly, or perhaps set a content section if the page is
> > dynamic).
> >
> > Regards,
> > David
> >   -----Original Message-----
> >   From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
> >   Sent: Sunday, November 23, 2003 9:19 AM
> >   To: Struts Users Mailing List
> >   Subject: Inheritance in tile definitions II
> >
> >
> >   My thanks to all those who offered suggestions for my first problem.
> >
> >   Let's say that I have the following in a definitions file:
> >
> >     <!--
> >
===================================================================== -->
> >
> >         -->
> >     <!-- Form
> >        -->
> >
> >         -->
> >     <!--
> >
===================================================================== -->
> >     <definition name="form.layout" page="/layouts/formLayout.jsp">
> >       <put name="system-short-name" value="TDL"/>
> >       <put name="user-name" value="Guest"/>
> >       <put name="title"   value="Form Page Layout"/>
> >       <put name="header"  value="/common/header.jsp"/>
> >       <put name="content" value="${content}"/>
> >       <put name="footer"  value="/common/footer.jsp"/>
> >       <put name="debug"   value="/debug.jsp"/>
> >     </definition>
> >     <definition name="login.form" extends="form.layout">
> >       <put name="title"   value="Login Form"/>
> >       <put name="content" value="/security/login.jsp"/>
> >     </definition>
> >
> >   When I access title using GetAsString from formLayout.jsp, I get the
> > expected value of Login Form.
> >
> >   How do I access the value of title from header.jsp?
> >
> >   Thank you,
> >   Ed
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>


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


RE: Inheritance in tile definitions II

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

The list archives describe this problem. I didn't understand it until I
tested it.

Inside the main definition, /layouts/formLayout.jsp, you'd normally have a
segment like this:

<tiles:get name="header"/>

Instead, they say to pass any tile-defined attribute, you must use an insert
and put in the place where you include that "included" page such as:

<tiles:insert attribute="header">
<tiles:put name="title" beanName="title" beanScope="tile" />
</tiles:insert>

This is odd but did indeed work for me a second ago to show my title in my
header.jsp using <tile:getAsString name="title" />

It came from here:
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg61368.html

Regards,
David

-----Original Message-----
From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
Sent: Sunday, November 23, 2003 12:32 PM
To: Struts Users Mailing List
Subject: Re: Inheritance in tile definitions II


When I simply place a getAsString in the header.jsp, I get an error message
which says that title can not be found in the context.  I get the same for
useAttribute.

Ed
----- Original Message -----
From: "David Friedman" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, November 23, 2003 12:22 PM
Subject: RE: Inheritance in tile definitions II


> Ed,
>
> The tile definition is initialized before the pages/jsp's/actions are
> called.  You can therefore access any name in any component as long as
that
> component is tiles aware.  In the case of your JSP's, juse use the tiles
> taglib and do what you did in header.jsp to obtain the title (a
getAsString,
> if I recall correctly).  In the case of an action, you'd need to subclass
> the TilesAction to manipulate it directly (i.e. to set the title from
within
> the Action directly, or perhaps set a content section if the page is
> dynamic).
>
> Regards,
> David
>   -----Original Message-----
>   From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
>   Sent: Sunday, November 23, 2003 9:19 AM
>   To: Struts Users Mailing List
>   Subject: Inheritance in tile definitions II
>
>
>   My thanks to all those who offered suggestions for my first problem.
>
>   Let's say that I have the following in a definitions file:
>
>     <!--
> ===================================================================== -->
>
>         -->
>     <!-- Form
>        -->
>
>         -->
>     <!--
> ===================================================================== -->
>     <definition name="form.layout" page="/layouts/formLayout.jsp">
>       <put name="system-short-name" value="TDL"/>
>       <put name="user-name" value="Guest"/>
>       <put name="title"   value="Form Page Layout"/>
>       <put name="header"  value="/common/header.jsp"/>
>       <put name="content" value="${content}"/>
>       <put name="footer"  value="/common/footer.jsp"/>
>       <put name="debug"   value="/debug.jsp"/>
>     </definition>
>     <definition name="login.form" extends="form.layout">
>       <put name="title"   value="Login Form"/>
>       <put name="content" value="/security/login.jsp"/>
>     </definition>
>
>   When I access title using GetAsString from formLayout.jsp, I get the
> expected value of Login Form.
>
>   How do I access the value of title from header.jsp?
>
>   Thank you,
>   Ed
>


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


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


Re: Inheritance in tile definitions II

Posted by Ed Dowgiallo <ed...@ptdprolog.net>.
When I simply place a getAsString in the header.jsp, I get an error message
which says that title can not be found in the context.  I get the same for
useAttribute.

Ed
----- Original Message -----
From: "David Friedman" <hu...@ix.netcom.com>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Sunday, November 23, 2003 12:22 PM
Subject: RE: Inheritance in tile definitions II


> Ed,
>
> The tile definition is initialized before the pages/jsp's/actions are
> called.  You can therefore access any name in any component as long as
that
> component is tiles aware.  In the case of your JSP's, juse use the tiles
> taglib and do what you did in header.jsp to obtain the title (a
getAsString,
> if I recall correctly).  In the case of an action, you'd need to subclass
> the TilesAction to manipulate it directly (i.e. to set the title from
within
> the Action directly, or perhaps set a content section if the page is
> dynamic).
>
> Regards,
> David
>   -----Original Message-----
>   From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
>   Sent: Sunday, November 23, 2003 9:19 AM
>   To: Struts Users Mailing List
>   Subject: Inheritance in tile definitions II
>
>
>   My thanks to all those who offered suggestions for my first problem.
>
>   Let's say that I have the following in a definitions file:
>
>     <!--
> ===================================================================== -->
>
>         -->
>     <!-- Form
>        -->
>
>         -->
>     <!--
> ===================================================================== -->
>     <definition name="form.layout" page="/layouts/formLayout.jsp">
>       <put name="system-short-name" value="TDL"/>
>       <put name="user-name" value="Guest"/>
>       <put name="title"   value="Form Page Layout"/>
>       <put name="header"  value="/common/header.jsp"/>
>       <put name="content" value="${content}"/>
>       <put name="footer"  value="/common/footer.jsp"/>
>       <put name="debug"   value="/debug.jsp"/>
>     </definition>
>     <definition name="login.form" extends="form.layout">
>       <put name="title"   value="Login Form"/>
>       <put name="content" value="/security/login.jsp"/>
>     </definition>
>
>   When I access title using GetAsString from formLayout.jsp, I get the
> expected value of Login Form.
>
>   How do I access the value of title from header.jsp?
>
>   Thank you,
>   Ed
>


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


RE: Inheritance in tile definitions II

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

The tile definition is initialized before the pages/jsp's/actions are
called.  You can therefore access any name in any component as long as that
component is tiles aware.  In the case of your JSP's, juse use the tiles
taglib and do what you did in header.jsp to obtain the title (a getAsString,
if I recall correctly).  In the case of an action, you'd need to subclass
the TilesAction to manipulate it directly (i.e. to set the title from within
the Action directly, or perhaps set a content section if the page is
dynamic).

Regards,
David
  -----Original Message-----
  From: Ed Dowgiallo [mailto:edowgial@ptdprolog.net]
  Sent: Sunday, November 23, 2003 9:19 AM
  To: Struts Users Mailing List
  Subject: Inheritance in tile definitions II


  My thanks to all those who offered suggestions for my first problem.

  Let's say that I have the following in a definitions file:

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

        -->
    <!-- Form
       -->

        -->
    <!--
===================================================================== -->
    <definition name="form.layout" page="/layouts/formLayout.jsp">
      <put name="system-short-name" value="TDL"/>
      <put name="user-name" value="Guest"/>
      <put name="title"   value="Form Page Layout"/>
      <put name="header"  value="/common/header.jsp"/>
      <put name="content" value="${content}"/>
      <put name="footer"  value="/common/footer.jsp"/>
      <put name="debug"   value="/debug.jsp"/>
    </definition>
    <definition name="login.form" extends="form.layout">
      <put name="title"   value="Login Form"/>
      <put name="content" value="/security/login.jsp"/>
    </definition>

  When I access title using GetAsString from formLayout.jsp, I get the
expected value of Login Form.

  How do I access the value of title from header.jsp?

  Thank you,
  Ed