Figure 8-6.Locale-aware formatting, this time in French
Additional Velocity Views
A final note on Velocity support: There are two additional views extending from VelocityView
that you may recall from Figure 7-1 in Chapter 7.
- VelocityToolboxViewoffers the ability to load tools from a standardtoolbox.xmlcon-
figuration file (see the Velocity documentation for details of toolboxes). On your View,
set the property toolboxConfigLocationto the location oftoolbox.xml. You can option-
ally set this property on VelocityViewResolvertoo, in which case everything resolved by
the resolver will be of type VelocityToolboxView. - VelocityLayoutViewfurther extends VelocityToolboxViewand supports similar function-
ality to what you obtain by using the native VelocityLayoutServlet(part of the Velocity
distribution, not Spring). A VelocityLayoutViewconsists of two distinct templates: the
layout template and the main content template. When the model is rendered, initially
the content template is merged with the model and placed in a Velocity variable named
screen_content. The model is then merged again with the layout template, which has
access to $screen_contentin order to place it anywhere in the layout. VelocityLayoutView
can be a good option if you want standard layouts for different content views, although
you may be better served investigating other technologies such as SiteMesh (http://
http://www.opensymphony.com/sitemesh)) to achieve this.
Summary
In this section, we’ve covered Spring’s support for two of the major open-source templating
solutions available to you. We’ve shown how to set up your MVC application to enable a
smooth integration, and we examined the significant value-added extras in the form of
Spring’s form-handling macros.
At this stage, you should be in a position to decide whether Velocity or FreeMarker is a
suitable view tier technology for your applications, and how to go about writing that layer with
confidence. If you decide upon Velocity, you might like to investigate Pro Jakarta Velocityby
Rob Harrop (Apress, 2004).
CHAPTER 8 ■SUPPORTED VIEW TYPES 249