Reputation: 27899
I'm using HibernateValidator
to validate forms in JSP using Spring MVC 3.0.2. Earlier, I was using the Validator
interface to validate forms where it was possible to disallow validation when certain event occurs.
For the sake of demonstration, I have one form on a JSP page where there are only two text fields and a submit button. When those fields are filled with appropriate values and the submit button is clicked, validation is performed first and values are inserted into the database, if any validation rule is not violated. It works fine.
There are also other submit buttons on the form to perform other operations like update and delete. Therefore when such buttons are clicked, the validation on those text fields is unnecessary and must not be performed. Is there a way to turn off or disallow validation at run time when certain such events occur?
Upvotes: 2
Views: 1932
Reputation: 120811
Jsr 303 has the concept of validation groups. This allows to validate validation rules of only a specified group. I am sure that I have answered a question like this on so some time ago, but at the moment I have only a mobile phone, so it is pain in the ass to search for this question
Upvotes: 2