Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in ValidationUtils

 
Anupam Dee
Ranch Hand
Posts: 42
Firefox Browser Tomcat Server Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two fields in Person Class
firstName
secondName

I want to validate that both the names should be given by the user at the same time

ValidationUtils only gives the method to check on a particular field, how can I validate this?
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can do client side validation using javascript.


Put hibernate validator on your class path.

http://www.hibernate.org/subprojects/validator.html


In your spring controller you can add @Valid to the model object you wish to validate. Then just use the JSR-303 annotations on your fields. Like @NotBlank or @NotNull.

Here is an example.
http://blog.springsource.org/2009/12/21/mvc-simplifications-in-spring-3-0/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic