Results 1 to 2 of 2

Thread: Velocity templates need help

  1. #1

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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.
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

Similar Threads

  1. Replies: 2
    Last Post: Jul 25th, 2005, 04:51 AM
  2. FreeMarker vs Velocity
    By Martin Kersten in forum Architecture
    Replies: 8
    Last Post: May 30th, 2005, 09:21 AM
  3. Velocity OutOfMemoryError during UnitTests
    By camach in forum Container
    Replies: 2
    Last Post: May 26th, 2005, 05:28 PM
  4. Using Long in velocity templates
    By paul.barry in forum Web
    Replies: 1
    Last Post: May 9th, 2005, 07:34 AM
  5. Replies: 3
    Last Post: Oct 19th, 2004, 09:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •