• 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
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Spring MVC: Binding and Validation

 
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

In Spring MVC, while using a concrete subclass of BaseCommandController, the behavior is such that even if binding of a particular property fails (due to wrong format while using PropertyEditor), the corresponding validation routine is still invoked. Now, if the property is a 'required' one, we get two distinct error-messages for the same property - one complaining about the format and another about the mandatory requirement.

Is this how it is supposed to be... or am I missing something here?

I'm using a Date property, and want to have my page working whether or not client-side (JavaScript) validation is enabled.

Thanks & regards,

- Aditya Jha
 
Aditya Jha
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

To be consistent with Declare-Post-In-Other-Forums policy, I would like to inform that I've asked this question at SpringFramework Forum also.

To my plight, it hasn't helped much there as well.

Anyone care to share thoughts on this? I see this question as a theoritical one, and any suggestions are welcome (not necessarily practical ones).

Thanks & regards,

- Aditya Jha
 
Ranch Hand
Posts: 225
Eclipse IDE Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The Errors object that is passed into your validator should have the previous binding errors already on it, so you can test the whole object or individual fields before validating them. (Warning - untested code!)



Or:

 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic