File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Problem in ValidationUtils Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Problem in ValidationUtils" Watch "Problem in ValidationUtils" New topic
Author

Problem in ValidationUtils

Anupam Dee
Ranch Hand

Joined: Oct 18, 2010
Posts: 42

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

Joined: Mar 07, 2010
Posts: 1666
    
    7

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/


[How To Ask Questions][Read before you PM me]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem in ValidationUtils