• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Spring MVC : InitBinder for non form values.

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I'm using Spring 2.5 with Spring MVC and annotations.

I have a controller with an @InitBinder method which I use for binding dates using a SimpleDateFormatter. This works great for form items, as these go through the binder.

My question is - is it possible for non-form items (Model Attributes) on the jsp page to use the same binder to convert date formats? I don't want to use the <fmt> tag if possible, as I would like to be able to change the format throughout the whole app in one go if required (I've actually implemented the InitBinder as a global binder)

In other words, the dates on the page are view only. They are from a model object, but are not bound to a form, but I still want them formatted the same way as the dates which are bound and therefore use the InitBinder property editor for Date objects.

Thanks in advance for any info.
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
InitBinder is not supposed to use like that.

You may consider to use FreeMarker as it supports specifying default date_format.
 
Kevin McMahon
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I figured as much. It's too late to use FreeMarker now as the pages are already written in jsp and there isn't time to change them.

Feels odd to me that using jsp/jstl/spring mvc there isn't a standard way which by default allows all dates to be displayed in a consistent format according the user's locale...

Ah well... we'll work around it. Ta.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic