You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Niall Gallagher <ni...@analog.com> on 2004/02/12 13:11:00 UTC

Simple and Velocity

Hi,

I have recently developed bindings for Velocity and Simple [1] that 
enables complex layouts to be generated. This extends the idea of the 
VelocityLayoutServlet and enables an arbitrary depth of layout to be 
achieved using Document objects that wrap Velocity templates. For 
example, documents can be added to each other like.

OutputStream out = request.getOutputStream();

Document layout = sys.lookup("layout.vm");
Document navBar = sys.lookup("navigation.vm");
Document body = sys.lookup("main.vm");

body.put("title", "My Title");
body.put("color", "Red");
body.put("navigation", navBar);

layout.put("body", body);

layout.write(out);

It also requires much less code to develop controller objects and 
enables a common set of tools to be added to any created Document 
object. The library can be downloaded from the Simple 2.3.3 download 
page [2] and the source code and documentation is also available there.

Thanks!
Niall

[1] http://simpleweb.sourceforge.net/
[2] http://simpleweb.sourceforge.net/download



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


Re: Simple and Velocity

Posted by Niall Gallagher <ni...@analog.com>.
Hi

>>I'm sure it could, all that is required to adapt this for use with the
>>VelocityLayoutServlet is to modify and perhaps repackage the
>>DocumentFactory to use the Velocity object rather than a VelocityEngine
>>instance. In this way you will be simply wrapping the Template objects
>>that are being used with Document objects.
>>    
>>
>
>cool.  then this'll be worth looking into one of these days (post 1.1 :).
>i'll make a note to myself about it.  of course, if you ever wanted to take a
>stab at it, that'd be cool too! :)
>  
>
No, problem. I'll rewrite a version of it to use the Velocity object. It 
shouldent be too much hassle, and if everything goes well ill let you know.

Niall


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


Re: Simple and Velocity

Posted by Niall Gallagher <ni...@analog.com>.
>>Uh... Hate to throw the damp towel on this...and likely I'm just being
>>dense, but, I'm sorry I just don't get it.
>>
>>How is hard coding template names in the servlet a Good Thing(tm)?
>>
>
>IMHO, it's not.  ...except perhaps as a proof of concept that can be later
>refined. :)
>
The names do not need to be hardcoded, I just provided a very simple 
example to explain the concept.

>>The example above looks pretty much like what the VelocityLayoutServlet
>>does automatically... so what am I missing? For arbitrary nesting, isn't
>>that what Tiles does?
>>
The API  I implemented the framework for does not use the Servlet API or 
Struts, so I implemented somthing similar that is not tied to either.

>>For example, if I were using Struts with *.vm mapped to
>>VelocityLayoutServlet... can't I achieve the exact same doing this:
>>
>>context.put("title", "My Title");
>>context.put("color", "Red");
>>return mapping.findForward("MainPage"); // sends to main.vm
>>
>>main.vm
>>---
>>$title - $color
>>---
>>
>>/layout/Default.vm
>>---
>>HEADER
>>#include ("navigation.vm")
>><HR>
>>$screen_content
>>FOOTER
>>---
>>
>>So please help me understand what I'm not seeing. :-)
>>
>
I think you probably see things quite well, there is nothing special/new 
going on here, its just a novell way to do a layout...






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


Re: Simple and Velocity

Posted by Nathan Bubna <na...@esha.com>.
Tim Colson said:
> > > >>OutputStream out = request.getOutputStream();
> > > >>Document layout = sys.lookup("layout.vm");
> > > >>Document navBar = sys.lookup("navigation.vm");
> > > >>Document body = sys.lookup("main.vm");
> > > >>
> > > >>body.put("title", "My Title");
> > > >>body.put("color", "Red");
> > > >>body.put("navigation", navBar);
> > > >>
> > > >>layout.put("body", body);
> > > >>layout.write(out);
>
> > > >very cool looking!  do you think this arbitrary layout
> > depth design could
> > be easily adapted to the VelocityLayoutServlet itself?
>
> Uh... Hate to throw the damp towel on this...and likely I'm just being
> dense, but, I'm sorry I just don't get it.
>
> How is hard coding template names in the servlet a Good Thing(tm)?

IMHO, it's not.  ...except perhaps as a proof of concept that can be later
refined. :)

> The example above looks pretty much like what the VelocityLayoutServlet
> does automatically... so what am I missing? For arbitrary nesting, isn't
> that what Tiles does?

yep.  but tiles does a lot more, does it differently, and is tied into struts.

> For example, if I were using Struts with *.vm mapped to
> VelocityLayoutServlet... can't I achieve the exact same doing this:
>
> context.put("title", "My Title");
> context.put("color", "Red");
> return mapping.findForward("MainPage"); // sends to main.vm
>
> main.vm
> ---
> $title - $color
> ---
>
> /layout/Default.vm
> ---
> HEADER
> #include ("navigation.vm")
> <HR>
> $screen_content
> FOOTER
> ---
>
> So please help me understand what I'm not seeing. :-)

i think you see things quite well, except perhaps that we're just
exploring/entertaining an interesting idea here.  :)

trust me, i won't put this sorta thing into VelocityView unless the concept
works out well and seems useful.  and even then, i have higher priorities than
this after we get 1.1 out.  :)

Nathan Bubna
nathan@esha.com


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


RE: Simple and Velocity

Posted by Tim Colson <tc...@cisco.com>.
> > >>OutputStream out = request.getOutputStream();
> > >>Document layout = sys.lookup("layout.vm");
> > >>Document navBar = sys.lookup("navigation.vm");
> > >>Document body = sys.lookup("main.vm");
> > >>
> > >>body.put("title", "My Title");
> > >>body.put("color", "Red");
> > >>body.put("navigation", navBar);
> > >>
> > >>layout.put("body", body);
> > >>layout.write(out);

> > >very cool looking!  do you think this arbitrary layout 
> depth design could
> be easily adapted to the VelocityLayoutServlet itself?

Uh... Hate to throw the damp towel on this...and likely I'm just being
dense, but, I'm sorry I just don't get it. 

How is hard coding template names in the servlet a Good Thing(tm)?

The example above looks pretty much like what the VelocityLayoutServlet
does automatically... so what am I missing? For arbitrary nesting, isn't
that what Tiles does?

For example, if I were using Struts with *.vm mapped to
VelocityLayoutServlet... can't I achieve the exact same doing this:

context.put("title", "My Title");
context.put("color", "Red");
return mapping.findForward("MainPage"); // sends to main.vm

main.vm
---
$title - $color
---


/layout/Default.vm
---
HEADER
#include ("navigation.vm") 
<HR>
$screen_content
FOOTER
---

So please help me understand what I'm not seeing. :-)

Thanks,
Tim




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


Re: Simple and Velocity

Posted by Nathan Bubna <na...@esha.com>.
Niall Gallagher said:
> Hi
>
> >>OutputStream out = request.getOutputStream();
> >>
> >>Document layout = sys.lookup("layout.vm");
> >>Document navBar = sys.lookup("navigation.vm");
> >>Document body = sys.lookup("main.vm");
> >>
> >>body.put("title", "My Title");
> >>body.put("color", "Red");
> >>body.put("navigation", navBar);
> >>
> >>layout.put("body", body);
> >>
> >>layout.write(out);
> >>
> >
> >very cool looking!  do you think this arbitrary layout depth design could
be
> >easily adapted to the VelocityLayoutServlet itself?
> >
> I'm sure it could, all that is required to adapt this for use with the
> VelocityLayoutServlet is to modify and perhaps repackage the
> DocumentFactory to use the Velocity object rather than a VelocityEngine
> instance. In this way you will be simply wrapping the Template objects
> that are being used with Document objects.

cool.  then this'll be worth looking into one of these days (post 1.1 :).
i'll make a note to myself about it.  of course, if you ever wanted to take a
stab at it, that'd be cool too! :)

> >>
> >>[1] http://simpleweb.sourceforge.net/
> >>[2] http://simpleweb.sourceforge.net/download
> >>
> >
> >hmm.  i'd never heard of Simple before.  interesting project.
> >
>
> Cheers!
> Niall

Nathan Bubna
nathan@esha.com


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


Re: Simple and Velocity

Posted by Niall Gallagher <ni...@analog.com>.
Hi

>>OutputStream out = request.getOutputStream();
>>
>>Document layout = sys.lookup("layout.vm");
>>Document navBar = sys.lookup("navigation.vm");
>>Document body = sys.lookup("main.vm");
>>
>>body.put("title", "My Title");
>>body.put("color", "Red");
>>body.put("navigation", navBar);
>>
>>layout.put("body", body);
>>
>>layout.write(out);
>>
>
>very cool looking!  do you think this arbitrary layout depth design could be
>easily adapted to the VelocityLayoutServlet itself?
>
I'm sure it could, all that is required to adapt this for use with the 
VelocityLayoutServlet is to modify and perhaps repackage the 
DocumentFactory to use the Velocity object rather than a VelocityEngine 
instance. In this way you will be simply wrapping the Template objects 
that are being used with Document objects.

>>
>>
>>[1] http://simpleweb.sourceforge.net/
>>[2] http://simpleweb.sourceforge.net/download
>>
>
>hmm.  i'd never heard of Simple before.  interesting project.
>

Cheers!
Niall



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


Re: Simple and Velocity

Posted by Nathan Bubna <na...@esha.com>.
Niall Gallagher said:
> I have recently developed bindings for Velocity and Simple [1] that
> enables complex layouts to be generated. This extends the idea of the
> VelocityLayoutServlet and enables an arbitrary depth of layout to be
> achieved using Document objects that wrap Velocity templates. For
> example, documents can be added to each other like.
>
> OutputStream out = request.getOutputStream();
>
> Document layout = sys.lookup("layout.vm");
> Document navBar = sys.lookup("navigation.vm");
> Document body = sys.lookup("main.vm");
>
> body.put("title", "My Title");
> body.put("color", "Red");
> body.put("navigation", navBar);
>
> layout.put("body", body);
>
> layout.write(out);

very cool looking!  do you think this arbitrary layout depth design could be
easily adapted to the VelocityLayoutServlet itself?

> It also requires much less code to develop controller objects and
> enables a common set of tools to be added to any created Document
> object. The library can be downloaded from the Simple 2.3.3 download
> page [2] and the source code and documentation is also available there.
>
> Thanks!
> Niall
>
> [1] http://simpleweb.sourceforge.net/
> [2] http://simpleweb.sourceforge.net/download

hmm.  i'd never heard of Simple before.  interesting project.

Nathan Bubna
nathan@esha.com


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