struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Cedric Dumoulin <cedric.dumou...@lifl.fr>
Subject Re: Nesting Tiles within each other problem
Date Fri, 22 Feb 2002 17:39:13 GMT
  What doesn't work in your example is that at a time you insert page
/middle.jsp without passing it any attribute. This page use  an attribute in its
<insert> tag. You have two solution to pass the attribute :

   * while you do the <insert> :
      middle.jsp
     <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
     <tiles:insert attribute="anotherBody">
       <tiles:put beanName="anotherAttribute" beanScope="tile"/>
     </tiles:insert>

   * By defining a definition declaring the attribute, and then use the
     definition name rather than the page url.

  Remember that Tiles attribute values passed to a tile are only visible inside
this tile, not from its parent, neither from sub-tiles.

  Doesn't the following solution met your needs ? :

<definition name="simpleLayout" path="/simpleLayout.jsp">
       <put name="title" value="aBody"/>
       <put name="header" value="aHeader"/>
       <put name="footer" value="aFooter"/>
       <put name="menu" value="amenu"/>
 </definition>

<definition name="complexLayout" path="/complexLayout.jsp"
extends="simpleLayout">
       <put name="header" value="complexHeader"/>
       <put name="secondHeader" value="anotherHeader"/>
 </definition>

<definition name="aSimplePage" extends="simpleLayout">
       <put name="body" value="aPageBody"/>
 </definition>

<definition name="aComplexPage" extends="complexLayout">
       <put name="body" value="aPageBody2"/>
 </definition>

  Cedric


Ian Beaumont wrote:

> >>  You should either do  :
> >>   * Pass the attribute value when you insert the page
> >>   * Insert a definition using the page as layout, and declaring the
> attribute
>
> I'm not clear what you mean by either of these statements.
>
> What I want to achieve is for all my pages to have a base layout, and some
> of the pages have a slightly more complex layout, which itself is based on
> the base layout.
>
> Thanks
> Ian
>
> -----Original Message-----
> From: Cedric Dumoulin [mailto:cedric.dumoulin@lifl.fr]
> Sent: 22 February 2002 14:08
> To: Struts Users Mailing List
> Subject: Re: Nesting Tiles within each other problem
>
>   In your example, you insert definition /top, which by extensions use
> 'base.jsp' as layout. In this later, you do <insert attribute="body" />.
> Body
> value is page /middle.jsp, wich is inserted. But, /midle.jsp is a page, not
> a
> definition. In /midle.jsp, you do <insert attribute="anotherBody" />, but
> anotherBody is not defined for the page.
>
>   You should either do  :
>
>    * Pass the attribute value when you insert the page
>    * Insert a definition using the page as layout, and declaring the
> attribute
>
>   Cedric
>
> Ian Beaumont wrote:
>
> > I access it by going to "/myPage.do".  Here is an extract from the
> > struts-config.
> >
> >     <action    path="/myPage"
> >                type="com.categoric.criticallogistix.client.DoFirst"
> >                 scope="request" >
> >       <forward name="success"              path="/top"/>
> >     </action>
> >
> > DoFirst is just
> > import org.apache.struts.action.*;
> > import javax.servlet.http.*;
> >
> > public class DoFirst extends Action {
> >
> >     public ActionForward perform(
> >         ActionMapping aMapping,
> >         ActionForm aForm,
> >         HttpServletRequest aRequest,
> >         HttpServletResponse aResponse
> >     ) {
> >         return aMapping.findForward("success");
> >     }
> >
> > -----Original Message-----
> > From: Cedric Dumoulin [mailto:cedric.dumoulin@lifl.fr]
> > Sent: 22 February 2002 13:36
> > To: Struts Users Mailing List
> > Subject: Re: Nesting Tiles within each other problem
> >
> >   Sure it is possible.
> >   In your example, what url do you use to access the page ?
> >   Remember that a definition name is a logical name. It can not be used as
> > an
> > url. You can use it in <insert name="defName" />, or as the path of a
> Struts
> > forward.
> >
> > Ian Beaumont wrote:
> >
> > > I have a page, which uses <tiles:insert> to insert another page that
> also
> > > has a <tiles:insert>.  Is this possible?  I just keep getting a servlet
> > > exception.  Below is a simplified example of what I'm doing.
> > >
> > > base.jsp
> > > <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
> > > <html:html locale="true">
> > > <body>
> > > <tiles:insert attribute="body"/>
> > > </body>
> > > </html:html>
> > >
> > > middle.jsp
> > > <%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
> > > <tiles:insert attribute="anotherBody"/>
> > >
> > > top.jsp
> > > <p>Hello World</p>
> > >
> > > >From tiles definition
> > >     <definition name="/baseLayout" path="/base.jsp">
> > >       <put name="body" value=""/>
> > >     </definition>
> > >
> > >     <definition name="/middleLayout" extends="/baseLayout">
> > >       <put name="body" value="/middle.jsp"/>
> > >       <put name="anotherBody" value=""/>
> > >     </definition>
> > >
> > >     <definition name="/top" extends="/middleLayout">
> > >       <put name="anotherBody" value="/top.jsp"/>
> > >     </definition>
> > >
> > > The error I get on trying to display the page 'top' is:
> > > ServletException in:/middle.jsp] Error - Tag Insert : No value found for
> > > attribute 'anotherBody'.'
> > > Thanks
> > > Ian Beaumont
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:struts-user-unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail:
> > <mailto:struts-user-help@jakarta.apache.org>
>
> --
> To unsubscribe, e-mail:
> <mailto:struts-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail:
> <mailto:struts-user-help@jakarta.apache.org>


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


Mime
View raw message