A bit of additional information about using JSR-303 validation with Spring Web Flow. (See Spring MVC, JSR 303 Validation, and WebSphere.)

I was hoping to use this instead of custom Java code with my Spring MVC/WebFlow application, but I think there are enough limitations in the simple use case (like non-deterministic validation ordering), that I’ll probably stick with Java Validator code for now.

But, so that I don’t lose the quick summary of it - that can doubtless be found lots of other places as well - I’m going to document it here.

Spring XML config like this:

<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>

<webflow:flow-builder-services id="flowBuilderServices" validator="validator" ... />

Then annotations like:

@Pattern(regexp = "^[\\w]{1,7}$", message="{plateNumber.pattern}")  
private String plateNumber;

And ValidationMessages.properties entries like:

plateNumber.pattern=Plate Number must be 1-7 alphabetic, numeric, or space characters