0
votes

We have developed an internet bank project in our company. We have used spring-mvc in this project and all of property validations have been carried out using Hibernate validator. However for some of our services that have a state-machine nature, we need to use spring-webflow.

In doing so we need to validate models in spring webflow without adding any extra validators. As you know There are 2 ways to validate a model programmatically:

  1. Define validation logic in the model object.
  2. Define a separate object called Validator to validate the model.

However, we DO NOT want to use none of these validation techniques.

For example lets imagine we had a Class named Customer. We used annotation validation for the properties in this class in our project. Now, we want to use this class as a model in view states in our webflow.

I was wondering if someone could help us how to validate models in spring webflow using annotation validation with hibernate validator.

1
Yes I am one the followers of mkyong page. As I said before We want to use Spring-webflow. this example in mkyong page is for spring-mvc validation not for spring-webflow - Himan

1 Answers

0
votes

Spring Webflow 2.4 supports JSR-303 validation and partial validation through the use of validation groups.

You need to add the following to the application context xml file:

<webflow:flow-registry flow-builder-services="flowBuilderServices" />

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

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

This will allow you to validate your model objects using annotations.