Announcement Announcement Module
No announcement yet.
Velocity templates need help Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Velocity templates need help

    Its somewhat disappointing that both WebWork and Spring which have out-of-box support for Velocity (which is great!) seem to treat Velocity like JSP (which is bad!) in the rendering aspect.

    Velocity templates cannot stand-alone (unlike JSP), and almost always need to be accompanied by some kind of template helper (action/controller) to retrieve the objects they need and stuff them into their context.

    Really, I don't see very much value in forwarding directly to a Velocity template without going through a template helper, unless you've got sophisticated Turbine-style Pull tools (ick!) or the template only uses the context tools.

    When using WebWork, I found myself declaring a View abstract class which subclasses Action, and all template helper classes subclass View.

    What's the recommended way of doing this in Spring? As an Interceptor, or simply by adding one Controller per template? Or am I missing something completely?

  • #2
    I think you've missed how the Spring VelocityView works. It takes the model Map and makes those objects available to the Velocity context. Isn't that what you mean?

    Spring does not treat Velocity like JSP. It adds a "model" abstraction that is independent of the Servlet API.

    With Spring MVC you should not bind the model to request attributes. This is incorrectly JSP-centric, and not the intent of Spring. Use the ModelAndView return type from Controller objects.