Posts

Showing posts from March, 2011

How-To: JSR303 validation groups in Spring MVC 3 wizard-style controllers

Beginning with Spring 3, Spring MVC has the ability to automatically validate @Controller inputs. To trigger validation of a @Controller input, simply annotate the input argument as javax.validation.Valid . Simple. But there is one drawback with automatic validation: using JSR303 validation groups is not possible. A group defines a subset of constraints. Instead of validating all constraints for a given object, only a subset is validated. Each constraint declaration defines the list of groups it belongs to. To trigger group validation group class or classes need to be passed to the validator. As mentioned, validation is triggered by with @Valid annotation. and there is no way you say which validation groups should be used in validation of @Controller input parameter. Until Spring 3.1 is ready and solves the problem, to utilize JSR303 validation groups manual validation is needed. Note: Have a look at the follow up post that describes the automatic validation with Spring's @

Codeleak.pl Started!

package pl.codeleak; public class Codeleak { public static void main(String[] args) { System.out.println("Blog started..."); } }