You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by je...@optonline.net on 2004/01/12 08:34:03 UTC

Tiles put scope?

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


Re: Tiles put scope?

Posted by "Marino A. Jonsson" <ma...@hotmail.com>.
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" <ma...@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 containing
the
> 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�
>
>
> <je...@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


Re: Tiles put scope?

Posted by "Marino A. Jonsson" <ma...@hotmail.com>.
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 containing the
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�


<je...@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