Using bean validation
Java Bean Validation—JSR-303 is a framework that has been approved by the JCP (Java Community Process) and is accepted as a part of the Java EE 6 specification. Through this framework, we can easily add validation on the attributes in the bean. In this recipe, we will create a form for the Product
bean and we will validate the attributes.
Getting ready
Before we start with bean validation, we need to download a Bean Validation implementation and add it to our project. For example, one of them is available at the following URL:
http://code.google.com/p/agimatec-validation/downloads/list
Alternatively, we can download the Hibernate Validator from the following URL:
http://www.hibernate.org/subprojects/validator/download
Or add the Maven dependency:
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>4.3.1.Final</version> </dependency>
Hibernate Validator requires slf4j...