You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Jeff Schnitzer <je...@infohazard.org> on 2001/06/19 12:28:04 UTC

Applying common look-and-feel

We released version 0.9.6 of Maverick, which adds the ability to define
<param> tags in the definition of velocity views to predefine entries in
the context.

As I was rewriting our velocity sample application, I noticed one mild
disadvantage to using "trim templates" (for lack of a better term) like
this:

<html>
	<head>
		<title> $title </title>
	</head>
	<body>
		<table>
			<tr>
				<td> <h1> $title </h1> </td>
			</tr>
			<tr>
				<td> <href="welcome.m">Login</a> </td>
				<td> <href="signup.m">Sign Up</a> </td>
			</tr>
		</table>
		#parse($content)
	</body>
</html>

And a Maverick command definition which uses the template like this:

<command id="welcome">
	<view>
		<velocity model="model" path="trimOutside.vm">
			<param name="title" value="Welcome"/>
			<param name="content" value="welcome.vm"/>
		</velocity>
	</view>
</command>

Now, this works pretty well, but it requires putting the title of every
page in the config file.  Not something I would necessarily lose sleep
over, but it's not quite as nice as leaving it in the welcome.vm
template.  I suppose the title could be left in a separate file, but
having two templates for each view would be rather annoying.

Are there any patterns I should be aware of that might avoid this?

Thanks,
Jeff Schnitzer
jeff@infohazard.org
Maverick:  http://mav.sourceforge.net

Re: Applying common look-and-feel

Posted by Scott Hernandez <sk...@eecs.berkeley.edu>.
I went left, you went right; we never met on this thread... try again later?

----- Original Message ----- 
From: "Geir Magnusson Jr." <ge...@optonline.net>
To: <ve...@jakarta.apache.org>
Sent: Wednesday, June 20, 2001 12:52 PM
Subject: Re: Applying common look-and-feel


{snip}

> > Now, this works pretty well, but it requires putting the title of every
> > page in the config file.  Not something I would necessarily lose sleep
> > over, but it's not quite as nice as leaving it in the welcome.vm
> > template.  I suppose the title could be left in a separate file, but
> > having two templates for each view would be rather annoying.

This was Jeff's comment...


Re: Applying common look-and-feel

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Scott Hernandez wrote:
> 
> Of course... :)

I think you were responding to my rhetorical question :

"If the title is content dependent, do you have a choice?"

Which was a response to your comment :

> Now, this works pretty well, but it requires putting the title of every
> page in the config file.  Not something I would necessarily lose sleep
> over, but it's not quite as nice as leaving it in the welcome.vm
> template.  I suppose the title could be left in a separate file, but
> having two templates for each view would be rather annoying.

What I meant to say was that if you don't/can't keep the title within
the document - for example, if you are skinning and putting the docs
into frames - then yes, you have a 'duple' of title + page, and you have
to keep them together somehow.

> 
> In addition to the context param(s) (which are optional), you are also
> passed the context model (which exists if you have a controller).
> 
> <command id="welcome">
>         <controller type="org.something.class"/>
>         <view>
>                 <!-- the model from org.something.class.model() is named
> model and inserted into the context for trimOutside.vm -->
>                 <velocity model="model" path="trimOutside.vm">
>                         <param name="title" value="Welcome"/>
>                         <param name="content" value="welcome.vm"/>
>                 </velocity>
>         </view>
> </command>
> 
> So you could something like this...
> <html>
>         <head>
>                 <title> $model.Title </title>
>         </head>
>     ...
> Or an if to check which one you may want (the model title, or the param
> title), like Christoph suggests in his email about his layout.vm.
> 
> Does that work for ya?

Yes - that illustrates my badly made point was that you have to match
the title to the page somewhere....

geir
-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: Applying common look-and-feel

Posted by Scott Hernandez <sk...@eecs.berkeley.edu>.
Of course... :)

In addition to the context param(s) (which are optional), you are also
passed the context model (which exists if you have a controller).

<command id="welcome">
        <controller type="org.something.class"/>
        <view>
                <!-- the model from org.something.class.model() is named
model and inserted into the context for trimOutside.vm -->
                <velocity model="model" path="trimOutside.vm">
                        <param name="title" value="Welcome"/>
                        <param name="content" value="welcome.vm"/>
                </velocity>
        </view>
</command>

So you could something like this...
<html>
        <head>
                <title> $model.Title </title>
        </head>
    ...
Or an if to check which one you may want (the model title, or the param
title), like Christoph suggests in his email about his layout.vm.

Does that work for ya?

later,
skot

----- Original Message -----
From: "Geir Magnusson Jr." <ge...@optonline.net>
To: <ve...@jakarta.apache.org>
Sent: Tuesday, June 19, 2001 3:41 AM
Subject: Re: Applying common look-and-feel


> If the title is content dependent, do you have a choice?
>
> geir
>
> Jeff Schnitzer wrote:
> >
> > We released version 0.9.6 of Maverick, which adds the ability to define
> > <param> tags in the definition of velocity views to predefine entries in
> > the context.
> >
> > As I was rewriting our velocity sample application, I noticed one mild
> > disadvantage to using "trim templates" (for lack of a better term) like
> > this:
> >
> > <html>
> >         <head>
> >                 <title> $title </title>
> >         </head>
> >         <body>
> >                 <table>
> >                         <tr>
> >                                 <td> <h1> $title </h1> </td>
> >                         </tr>
> >                         <tr>
> >                                 <td> <href="welcome.m">Login</a> </td>
> >                                 <td> <href="signup.m">Sign Up</a> </td>
> >                         </tr>
> >                 </table>
> >                 #parse($content)
> >         </body>
> > </html>
> >
> > And a Maverick command definition which uses the template like this:
> >
> > <command id="welcome">
> >         <view>
> >                 <velocity model="model" path="trimOutside.vm">
> >                         <param name="title" value="Welcome"/>
> >                         <param name="content" value="welcome.vm"/>
> >                 </velocity>
> >         </view>
> > </command>
> >
> > Now, this works pretty well, but it requires putting the title of every
> > page in the config file.  Not something I would necessarily lose sleep
> > over, but it's not quite as nice as leaving it in the welcome.vm
> > template.  I suppose the title could be left in a separate file, but
> > having two templates for each view would be rather annoying.
> >
> > Are there any patterns I should be aware of that might avoid this?
> >
> > Thanks,
> > Jeff Schnitzer
> > jeff@infohazard.org
> > Maverick:  http://mav.sourceforge.net




Re: Applying common look-and-feel

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
If the title is content dependent, do you have a choice?

geir

Jeff Schnitzer wrote:
> 
> We released version 0.9.6 of Maverick, which adds the ability to define
> <param> tags in the definition of velocity views to predefine entries in
> the context.
> 
> As I was rewriting our velocity sample application, I noticed one mild
> disadvantage to using "trim templates" (for lack of a better term) like
> this:
> 
> <html>
>         <head>
>                 <title> $title </title>
>         </head>
>         <body>
>                 <table>
>                         <tr>
>                                 <td> <h1> $title </h1> </td>
>                         </tr>
>                         <tr>
>                                 <td> <href="welcome.m">Login</a> </td>
>                                 <td> <href="signup.m">Sign Up</a> </td>
>                         </tr>
>                 </table>
>                 #parse($content)
>         </body>
> </html>
> 
> And a Maverick command definition which uses the template like this:
> 
> <command id="welcome">
>         <view>
>                 <velocity model="model" path="trimOutside.vm">
>                         <param name="title" value="Welcome"/>
>                         <param name="content" value="welcome.vm"/>
>                 </velocity>
>         </view>
> </command>
> 
> Now, this works pretty well, but it requires putting the title of every
> page in the config file.  Not something I would necessarily lose sleep
> over, but it's not quite as nice as leaving it in the welcome.vm
> template.  I suppose the title could be left in a separate file, but
> having two templates for each view would be rather annoying.
> 
> Are there any patterns I should be aware of that might avoid this?
> 
> Thanks,
> Jeff Schnitzer
> jeff@infohazard.org
> Maverick:  http://mav.sourceforge.net

-- 
Geir Magnusson Jr.                           geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
You have a genius for suggesting things I've come a cropper with!

Re: Applying common look-and-feel

Posted by Scott Hernandez <sk...@eecs.berkeley.edu>.
Email is best for now. :)

----- Original Message -----
From: "Jon Stevens" <jo...@latchkey.com>
Sent: Wednesday, June 20, 2001 11:44 AM
Subject: Re: Applying common look-and-feel


> Hey Scott,
> on 6/20/01 9:36 AM, "Scott Hernandez" <sk...@eecs.berkeley.edu> wrote:
> > In what ways?
> > Are you referring to page layout stuff? Or something specific to
velocity
> > templating implementation?
> >
> > We are always looking for suggestions... :)
> Come over to my house sometime, I'll buy you lunch at Bel Forno and we can
> discuss. :-)

Thanks for the offer, next time I'm in Berkeley I'll take you up on it. I'm
currently in San Luis Obispo; down south.

> whois latchkey.com
> > <skot smpt:address="skot@eecs.berkeley.edu" />
> You got the protocol wrong...it is smtp.

oopsss...

> :-)
> -jon


Re: Applying common look-and-feel

Posted by Jon Stevens <jo...@latchkey.com>.
Hey Scott,

on 6/20/01 9:36 AM, "Scott Hernandez" <sk...@eecs.berkeley.edu> wrote:

> In what ways?
> 
> Are you referring to page layout stuff? Or something specific to velocity
> templating implementation?
> 
> We are always looking for suggestions... :)

Come over to my house sometime, I'll buy you lunch at Bel Forno and we can
discuss. :-)

whois latchkey.com

> <skot smpt:address="skot@eecs.berkeley.edu" />

You got the protocol wrong...it is smtp.

:-)

-jon


Re: Applying common look-and-feel

Posted by Scott Hernandez <sk...@eecs.berkeley.edu>.
In what ways?

Are you referring to page layout stuff? Or something specific to velocity
templating implementation?

We are always looking for suggestions... :)

<skot smpt:address="skot@eecs.berkeley.edu" />
----- Original Message -----
From: "Jon Stevens" <jo...@latchkey.com>
Sent: Tuesday, June 19, 2001 9:24 AM
Subject: Re: Applying common look-and-feel

[SNIP]

Thanks for the excellent summary Christoph. Next, I'm sure that we will see
Maverick migrate to the Turbine Way. :-) It is only a matter of time. :-)

Thanks,

-jon



Re: Applying common look-and-feel

Posted by Jon Stevens <jo...@latchkey.com>.
on 6/19/01 5:02 AM, "Christoph Reck" <Ch...@dlr.de> wrote:

> The turbine approach using a layout template seems to be good.
> I used this in our applications, where we got:
> global VMs
> globals initialization template    _
> request processing template     --|
> view template                   --|  rendered per request
> layout template                 --|_
> 
> In trubine, one mode of operations is to address the desired template
> (the view). It has actions indirectly associated via a java class
> of the same name. Either the view, the action define the required
> layout template or the default layout is used.

Documented here:

http://jakarta.apache.org/turbine/fsd.html
and
http://jakarta.apache.org/turbine/howto/velocity-site-howto.html

> I hope this information is of help for someone.
> 
> :) Christoph

Thanks for the excellent summary Christoph. Next, I'm sure that we will see
Maverick migrate to the Turbine Way . :-) It is only a matter of time. :-)

Thanks,

-jon


Re: Applying common look-and-feel

Posted by Christoph Reck <Ch...@dlr.de>.
The turbine approach using a layout template seems to be good. 
I used this in our applications, where we got:
	global VMs
	globals initialization template    _
	request processing template     --| 
	view template                   --|  rendered per request
	layout template                 --|_

In trubine, one mode of operations is to address the desired template
(the view). It has actions indirectly associated via a java class
of the same name. Either the view, the action define the required 
layout template or the default layout is used.

In my approach, the action is determined by the request processing 
template (common for the web-app). It may #parse other VTL coded
controller templates and may override the view and the layout 
template.

I've place our layout template for public viewing and use on:
	http://www.eoweb.de:8888/eoweb/templates/layout.vm
It is well documented and parametrized (head meta tags, javascript, etc.), 
and could be taken over into turbine for use by the VelocityOnlyLayout.

You can see the whole application running at 
	http://www.eoweb.de:8888/eoweb/html/infeo

I hope this information is of help for someone.

:) Christoph


Jeff Schnitzer wrote:
> 
> We released version 0.9.6 of Maverick, which adds the ability to define
> <param> tags in the definition of velocity views to predefine entries in
> the context.
> 
> As I was rewriting our velocity sample application, I noticed one mild
> disadvantage to using "trim templates" (for lack of a better term) like
> this:
> 
> <html>
>         <head>
>                 <title> $title </title>
>         </head>
>         <body>
>                 <table>
>                         <tr>
>                                 <td> <h1> $title </h1> </td>
>                         </tr>
>                         <tr>
>                                 <td> <href="welcome.m">Login</a> </td>
>                                 <td> <href="signup.m">Sign Up</a> </td>
>                         </tr>
>                 </table>
>                 #parse($content)
>         </body>
> </html>
> 
> And a Maverick command definition which uses the template like this:
> 
> <command id="welcome">
>         <view>
>                 <velocity model="model" path="trimOutside.vm">
>                         <param name="title" value="Welcome"/>
>                         <param name="content" value="welcome.vm"/>
>                 </velocity>
>         </view>
> </command>
> 
> Now, this works pretty well, but it requires putting the title of every
> page in the config file.  Not something I would necessarily lose sleep
> over, but it's not quite as nice as leaving it in the welcome.vm
> template.  I suppose the title could be left in a separate file, but
> having two templates for each view would be rather annoying.
> 
> Are there any patterns I should be aware of that might avoid this?
> 
> Thanks,
> Jeff Schnitzer
> jeff@infohazard.org
> Maverick:  http://mav.sourceforge.net