• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

velocity tools and view technologies

 
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I looked at an example of org.apache.velocity.tools.generic.DateTool
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.
 
Author
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Karthik,

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.

Rob
 
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Who is the V responsible in Struts/SpringMVC + Velocity?

./pope
 
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic