File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Open Source Projects and the fly likes velocity tools and view technologies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "velocity tools and view technologies" Watch "velocity tools and view technologies" New topic

velocity tools and view technologies

Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
I looked at an example of
in the velocity tools project. In a web development context , whose responsibility it is to format data as required by the view? The model's / View's? If the model is supposed to take care of this then i'm not sure how relevant 'velocity tools' would be.

Why have the velocity folks gone out of their way to provide all this nice to have features. Is it because I dont have access to all java libraries in the template the way i would, if it were a jsp? I mean the only way some class would be available to a context is if its programmatically populated through the context right?

Are velocity tools classes like DateTool automatically available to a template through some magic :-) or i need to use some specific variable (like say $dateTool) to access those methods? Please bear with me I'm a velocity newbie.
Rob Harrop
Ranch Hand

Joined: Nov 03, 2004
Posts: 44

You correct in your assertion that the only objects available in a Velocity template are those that have been added to the context. This is why Velocity is particularly suitable for use in an MVC environment - it is difficult to break encapsulation and have the Velocity template start acting like a controller.

When using VelocityViewServlet, the DateTool (and other tools) are are added to the context using the toolbox.xml file. VVS is used when using Velocity directly from a servlet and when using Velocity with Struts. When using Velocity with Spring, Spring provides its own toolbox notion that works in an identical fashion to the VSS toolbox.

As for whose reponsibility it is to *format* the data, then I would say the View since, by defintion, the View is responsible for rendering the data from the Model to the user. If that data needs to be in a given format then the formatting is the responsibility of the View.

Alexandru Popescu
Ranch Hand

Joined: Jul 12, 2004
Posts: 995
Who is the V responsible in Struts/SpringMVC + Velocity?


blog -
I agree. Here's the link:
subject: velocity tools and view technologies
It's not a secret anymore!