Skip to Main Content
Java EE 6 Pocket Guide
book

Java EE 6 Pocket Guide

by Arun Gupta
September 2012
Intermediate to advanced content levelIntermediate to advanced
210 pages
3h 59m
English
O'Reilly Media, Inc.
Content preview from Java EE 6 Pocket Guide

Chapter 11. Bean Validation

Bean Validation is defined as JSR 303, and the complete specification can be downloaded from http://jcp.org/aboutJava/communityprocess/final/jsr303/index.html.

Bean Validation provides a class-level constraint declaration and validation facility for Java applications.

The constraints can be declared in the form of annotations placed on a field, property, method parameter, or class. Constraints can be defined on interfaces or superclasses. Specifying a constraint on an interface ensures the constraint is enforced on classes implementing the interface. Similarly, all classes inheriting from a superclass inherit the validation behavior as well. Constraints declared on an interface or superclass are validated along with any constraints defined on the implementing or overriding class.

Validation constraints and configuration information can also be defined through XML validation descriptors in META-INF/validation.xml. The descriptors override and extend the meta-data defined using annotations. This chapter will cover annotations-based constraint validations only.

A constraint metadata repository and an ability to query it is also available. This is primarily targeted toward tool developers as well as integration with other frameworks and libraries.

Built-in Constraints

A built-in set of constraint definitions are available that can be used on beans. Multiple constraints can be specified on a bean to ensure different validation requirements are met. These constraints ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java EE 7 Essentials

Java EE 7 Essentials

Arun Gupta
Beginning Java EE 7

Beginning Java EE 7

Antonio Goncalves
The Java EE 6 Tutorial: Advanced Topics, Fourth Edition

The Java EE 6 Tutorial: Advanced Topics, Fourth Edition

Eric Jendrock, Ricardo Cervera-Navarro, Ian Evans, Devika Gollapudi, Kim Haase, William Markito, Chinmayee Srivathsa

Publisher Resources

ISBN: 9781449338329Errata