tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick R <ric...@gmail.com>
Subject Re: should be super easy - but I'm screwing up using extends/nested..
Date Mon, 29 Aug 2011 18:02:13 GMT
On Mon, Aug 29, 2011 at 1:49 PM, Antonio Petrelli <
antonio.petrelli@gmail.com> wrote:

> 2011/8/29 Rick R <rickcr@gmail.com>
>
> > On Mon, Aug 29, 2011 at 1:38 PM, Rick R <rickcr@gmail.com> wrote:
> >
> > >
> > >
> > > On Mon, Aug 29, 2011 at 1:35 PM, Antonio Petrelli <
> > > antonio.petrelli@gmail.com> wrote:
> > >
> > >>
> > >> >
> > >> > Oh, I see something like this maybe (which works, although
> definitely
> > >> more
> > >> > verbose):
> > >> >
> > >> > <definition name="signup" extends="base.definition">
> > >> >  <put-attribute name="pageBody">
> > >> > <definition templateExpression="/WEB-INF/layouts/plainBody.jsp">
> > >> >  <put-attribute name="content"
> > >> value="/WEB-INF/views/signup/signup.jsp"/>
> > >> > </definition>
> > >> >  </put-attribute>
> > >> > </definition>
> > >> >
> > >>
> > >> It's not verbose, it's right.
> > >>
> > >>
> > >
> > >
> > > Ok so should that be preferred over using 'cascade=true' (which I'm
> > > thinking your suggesting it is.)
> > >
> > > I got that above down to a little more clear with the following (used
> > > extends on pageBody to plain.body so that template definition could be
> > > defined in a more common place.)
> > >
> > > <definition name="signup" extends="base.definition">
> > > <put-attribute name="pageBody">
> > >  <definition extends="plain.body">
> > > <put-attribute name="content"
> value="/WEB-INF/views/signup/signup.jsp"/>
> > >  </definition>
> > > </put-attribute>
> > > </definition>
> > >
> > >
> >
> > It is more verbose though but I prefer to do what is 'right' and won't
> get
> > me into trouble later. But here are the two side by side:
> >
> > BEFORE using cascade, most page definitions using the plain layout would
> > look like:
> >
> > <definition name="signup" extends="plainLayout">
> > <put-attribute name="content" value="/WEB-INF/views/signup/signup.jsp"
> > cascade="true"/>
> > </definition>
> >
> >
> > NOT using cascade and the nested definition:
> >
> > <definition name="signup" extends="base.definition">
> >  <put-attribute name="pageBody">
> > <definition extends="plain.body">
> >  <put-attribute name="content" value="/WEB-INF/views/signup/signup.jsp"/>
> > </definition>
> >  </put-attribute>
> > </definition>
> >
>
> There is no "right" thing to do. Cascade attributes have one problem: they
> are cascaded to every nested definition. This way you cannot have two
> sibling nested definitions that share the same attribute names. However, if
> it is not your case, cascade attributes allow an easier to read XML file.
>
> My suggestion is to *use cascade attributes* and use anonymous nested
> definitions to override any attributes with the same names as the cascaded
> ones, if you have this case.
>
> Antonio
>

Thanks you helped a lot!

-- 
Rick R

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message