Categories
Java Web Development

Using Velocity date tool with Spring MVC

I was having trouble getting Velocity‘s date tool to work with Spring MVC. I followed the instructions, most copied verbatim from what was most likely one ancient source. Those instructions said that to enable Velocity’s date formatting tool, DateTool, I needed to configure the VelocityViewResolver like this (WRONG):

<bean id="viewResolver">
  class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"></bean>
<br /><property name="numberToolAttribute"><value>numbertool</value></property>
<br /><property name="dateToolAttribute"><value>datetool</value></property>
&nbsp;

And then use it as:

$date.format("yyyy-MM-dd", $currentDate)

This would have been cool had I seen it in just one source but more than one source had it. The problem is small but crucial:

The value you give the dateToolAttribute property will be the name of the object Velocity will try to access when you are using the tool. So in the above configuration, the value for dateToolAttribute is “dateTool”, and hence the usage should be:

$dateTool.format(“yyyy-MM-dd”, $currentDate)

It may sound petty but it took me time to discover… lame.

Share
Categories
General

Firefox 3 – please wait

So I joined the hordes downloading Firefox 3. Download is slow if you are even successful, as they are aiming to break the download world record. That is fine, but even if you are successful, you end up with a Firefox version that very few of your beloved extensions (Firebug, Fireshot, Delicious and others) will work with out of the box or update automatically. No need to rush. It work and all – weee go Mozilla! – but I am downgrading right now – you can find a download of Firefox 2 that *does* work from Google.

Share
Share