Velocity

Using Velocity Toolbox Features in Spring

Today the need to URL encode some URLs within a Velocity view came up in a Spring application of mine. After a few failed attempts to get a LinkTool working, I found the issue. There was a problem with the formatting of my toolbox.xml file. I thought I'd better recap the complete setup for using Velocity toolbox views in Spring.

First, I define a VelocityViewResolver in my servlet beans configuration file (spring-servlet.xml). I define a
toolboxConfigLocation, and set it to /WEB-INF/classes/toolbox.xml. I change the viewClass to use the VelocityToolboxView class instead of VelocityView. Here's an excerpt of the important area:

Data Binding to Multiple Records in Spring (with Velocity)

A client came to me recently asking for modifications to their web application. The application has a many to one relationship; we'll call it the "one" side a Studio, and the "many" side's elements "Films". Updated information for films (box office numbers, tickets sold, etc) comes in batches. Searching, selecting and editing Films one at a time is inefficient, so the client requested batch editing ability.

We started from the user's perspective and decided a spreadsheet-style interface would be most efficient. Users will perform a search to get a list of Films, then edit them in the spreadsheet interface. This required data binding to multiple database records simultaneously.