velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jeich...@optonline.net
Subject Re: Tiles put scope?
Date Mon, 12 Jan 2004 18:48:30 GMT
That is the answer sir.  I had fully written out a response to your first write, and I was
still gnawing at this bone trying to figure out a better way.

Though not quite as easy as just being able to extend .default.template, this new code you
just showed is definately the best possible way to go.  I was close to this originally, but
didn't take it far enough.

I will implement it today.

Thank you very much for your help and work on Tiles.  I am enjoying Velocity very much and
find the Tiles addition quite useful.

John


----- Original Message -----
From: "Marino A. Jonsson" <marino_jonsson@hotmail.com>
Date: Monday, January 12, 2004 1:37 pm
Subject: Re: Tiles put scope?

> took a better look ... wrote a little hastily :)
> 
> Here is a more sane version (but the same principle):
> 
>      <definition name=".default.top"
> path="/WEB-INF/templates/pub/common/tiles/defaultTop.vm">
>          <put name="topTitle" value="Site Services" />
>          <put name="topScript" value="" />
>      </definition>
> 
>     <definition name=".default.template"
> path="/WEB-INF/templates/pub/common/tiles/defaultTemplate.vm">
>          <put name="top" value=".default.top" />
>          <put name="header"
> value="/WEB-INF/templates/pub/common/tiles/defaultHeader.vm" />
>          <put name="body"
> value="/WEB-INF/templates/pub/common/tiles/defaultBody.vm" />
>          <put name="footer"
> value="/WEB-INF/templates/pub/common/tiles/defaultFooter.vm" />
>      </definition>
> 
>      <definition name=".tile.post.search.top" extends=".default.top">
>            <put name="topScript"
> value="/WEB-
> INF/templates/pub/common/tiles/defaultFormJavascript.vm" />
>      </definition>
> 
>     <definition name=".tile.post.search" extends="defaultTemplate">
>        <put name="top" value=".tile.post.search.top" />
>        <put name="body"
> value="/WEB-INF/templates/pub/services/post/search/postsearch.vm" />
>     </definition>
> 
> 
> Hope this gives you a better idea.
> 
> cheers,
> MarinĂ³
> 
> 
> "Marino A. Jonsson" <marino_jonsson@hotmail.com> wrote in message
> news:btunkl$g0l$1@sea.gmane.org...
> > One simple way:
> >
> >      <definition name=".sharedHeadAttributes">
> >          <put name="topTitle" value="Site Services" />
> >          <put name="topScript" value="" />
> >      </definition>
> >
> >     <definition name=".defaultTemplate"
> > path="/WEB-INF/templates/pub/common/tiles/defaultTemplate.vm">
> >          <put name="top" value=".defaultTop" />
> >          <put name="header"
> > value="/WEB-INF/templates/pub/common/tiles/defaultHeader.vm" />
> >          <put name="body"
> > value="/WEB-INF/templates/pub/common/tiles/defaultBody.vm" />
> >          <put name="footer"
> > value="/WEB-INF/templates/pub/common/tiles/defaultFooter.vm" />
> >      </definition>
> >
> >      <definition name=".defaultTop"
> > path="/WEB-INF/templates/pub/common/tiles/defaultTop.vm"
> > extends=".sharedHeadAttributes" />
> >
> >
> > Create a definition with the attributes you want to share, put
> defaultTop.vm
> > in a definition of it's own, and let it extend the definition 
> containingthe
> > attributes.
> >
> > .defaultTemplate shiouldn't need to extend .sharedHeadAttributes if
> > .defaultTop does ... however if you want all templates that extend
> > .defaultTemplate to have access to these attributes you should 
> just let
> > .defaultTemplate extend .sharedHeadAttributes too.
> >
> > cheers,
> > MarinĂ³
> >
> >
> > <jeichels@optonline.net> wrote in message
> > news:42b356425b1c.425b1c42b356@optonline.net...
> > >
> > > I am beginning to convert a site to using Tiles, and I seem to 
> be having
> a
> > little problem understanding scope of variables defined within a 
> Tile.> >
> > > Basically I have a set of Tiles definitions (defined below) 
> and Master
> > Template defined towards the bottom.   The default template 
> works except
> > that my web page is created minus two minor problems.   The 
> topScript (aka
> > javascript) and topTitle seem to not being included within the
> sub-template
> > defaultTop.vm.
> > >
> > > How can a sub-template see the definitions.   I figured that 
> since the
> > variable was defined in defaultTemplate that defaultTop would be 
> able to
> see
> > it.  If not, then how can I pull out aspects of code like those 
> pieces and
> > not break with Tiles requirements.
> > >
> > > I hope this makes sense.
> > >
> > > John
> > >
> > >
> > >
> > >
> > > Tiles Defs follow:
> > > ----------------------
> > >
> > >     <definition name="defaultTemplate"
> > path="/WEB-INF/templates/pub/common/tiles/defaultTemplate.vm">
> > >         <put name="topTitle" value="Site Services" />
> > >         <put name="topScript" value="" />
> > >         <put name="top"
> > value="/WEB-INF/templates/pub/common/tiles/defaultTop.vm" />
> > >         <put name="header"
> > value="/WEB-INF/templates/pub/common/tiles/defaultHeader.vm" />
> > >         <put name="body"
> > value="/WEB-INF/templates/pub/common/tiles/defaultBody.vm" />
> > >         <put name="footer"
> > value="/WEB-INF/templates/pub/common/tiles/defaultFooter.vm" />
> > >     </definition>
> > >
> > >
> > >     <definition name="tile.welcome" extends="defaultTemplate">
> > >         <put name="body" value="/WEB-
> INF/templates/pub/home/welcome.vm"/>
> > >     </definition>
> > >
> > >
> > >
> > >     <definition name="tile.post.search" extends="defaultTemplate">
> > >         <put name="body"
> > value="/WEB-
> INF/templates/pub/services/post/search/postsearch.vm" />
> > >         <put name="topScript"
> > value="/WEB-
> INF/templates/pub/common/tiles/defaultFormJavascript.vm" />
> > >     </definition>
> > >
> > >     <definition name="tile.post.search.results"
> extends="defaultTemplate">
> > >         <put name="body"
> > value="/WEB-
> INF/templates/pub/services/post/search/postsearchresults.vm"/>
> > >     </definition>
> > >
> > >
> > >
> > >
> > >
> > > I had defined a simple master template as follows:
> > > ---------------------------------------------------------------
> --------
> > >
> > > <html>
> > > <head>
> > >     $!tiles.top
> > > </head>
> > > <body>
> > > <table>
> > > <tr><td valign="top" align="left">
> > >     $!tiles.header
> > > </td></tr>
> > > <tr><td valign="top"  align="left">
> > >     $!tiles.body
> > > </td></tr>
> > > <tr><td valign="top" align="left">
> > >     $!tiles.footer
> > > </td></tr>
> > > </table>
> > > </body>
> > > </html>
> 
> 
> 
> 
> -------------------------------------------------------------------
> --
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 


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


Mime
View raw message