• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the value prop of Velocity

 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Except for reading about it on forums; I haven't met any one using it locally near my area.

Can some one shed light on its relative advantages & how different this is from JSPs and other approaches for realizing web enablement.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Velocity is a template based generator. You create a context (which will feed with info) and the templates using the VTL.
I am not using Velocity for web based solution, but rather for code generation.

./pope
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ali Pope:
I am not using Velocity for web based solution, but rather for code generation.
./pope


Can you briefly tell us how you put that to use? I'm tryign to understand how this is different from say xdoclet. xdoclet has a template and then we have the xdoclet tags in the source code that it applies on the template and generates code.

From what i understand of velocity , we need to populate the context using java beans/ objects and the template would read out of it?

thanks.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Xdoclet and Velocity use in fact the same principles:
- collect data (creating a context)
- use templates
- extract needed data from context and fill in the template

afaik XDoclet2 has a Velocity engine inside.

./pope
 
Karthik Guru
Ranch Hand
Posts: 1209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.

- collect data (creating a context)

Yup this is the part am a little confused about. Xdoclet collects data from my source code. I mean it has the utils to parse the source and populate the context. How are you using velocity for code generation? I mean does it have an option to do data collection out of a file ? or you populate the velocity context with java objects that are then substituted in the template?
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am programmaticaly initializing the velocity context. afaik velocity has direct context feeders available.

./pope
 
Rob Harrop
Author
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The biggest value in Velocity comes from its simplicity and the ability to use it in a wide range of scenarios. The Velocity syntax is substantially easier to understand than JSP making it ideal for use with multi-disciplined teams.

As for XDoclet, it sources all the information it needs to render out from your source code and the metadata contained therein. With Velocity, you pass data to it manually using a Context object. As was mentioned in an earlier post, this is often performed automatically for you.

The VelocityViewServlet will map request/session/app params/attributes into the context for you, which is particularly useful when using Velocity with Struts. With Spring, the Velocity view classes will transfer data from the ModelAndView returned by your Controllers into the Velocity context. Both of these topics have coverage in the book.
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob I see more power in Velocity in a code generation scenario, rather than web solutions where more appropriate/powerful frameworks are already available (maybe this is really biased, as I do not have much to work with web based solutions ). In the code generation case one very powerful scenario I am facing/solved right now is Velocity + dtoGen. dtoGen allows cutting the model graph in a very easy and many possibility way, this giving birth to the velocity context.
I think this tandem can be easily be involved also in web solutions.

./pope
 
Rob Harrop
Author
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ali,

Velocity is certainly useful for code generation - we built a framework for generating basic CRUD functionality using Ant and Velocity that is really smooth. In the web tier, Velocity is not a replacement for powerful frameworks it is more of a complement. A typical solution we build would be Spring MVC + Velocity + our directive library.

JSP is a useful technology but it is too complex for my designers and the performance is quite disappointing. JSF is really interesting, especially consider the success the similar ASP.NET model has enjoyed but I am not yet that comfortable with any of the implementations and Velocity is very successful for me and my team.

Rob
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So your suggestion is that Spring MVC (guessing for MC part) + Velocity (as V part) forms a happy couple. What I am wondering is how the real web designers intervene in this?

./pope
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rob Harrop:
The biggest value in Velocity comes from its simplicity and the ability to use it in a wide range of scenarios. The Velocity syntax is substantially easier to understand than JSP making it ideal for use with multi-disciplined teams.

As for XDoclet, it sources all the information it needs to render out from your source code and the metadata contained therein. With Velocity, you pass data to it manually using a Context object. As was mentioned in an earlier post, this is often performed automatically for you.

The VelocityViewServlet will map request/session/app params/attributes into the context for you, which is particularly useful when using Velocity with Struts. With Spring, the Velocity view classes will transfer data from the ModelAndView returned by your Controllers into the Velocity context. Both of these topics have coverage in the book.


Thanks for the info Rob.

Can u shed a light on any high profile websites using Velocity from a web framework perspective?
 
Alexandru Popescu
Ranch Hand
Posts: 995
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can find a list of application and site based on Velocity here

./pope
 
Kishore Dandu
Ranch Hand
Posts: 1934
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ali Pope:
You can find a list of application and site based on Velocity here

./pope


Thanks Ali.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic