Document Information

Preface

Part I Introduction

1.  Overview

2.  Using the Tutorial Examples

Part II The Web Tier

3.  Getting Started with Web Applications

4.  Java Servlet Technology

5.  JavaServer Faces Technology

6.  Introduction to Facelets

7.  Using JavaServer Faces Technology in Web Pages

8.  Developing with JavaServer Faces Technology

Writing Bean Properties

Writing Properties Bound to Component Values

UIInput and UIOutput Properties

UIData Properties

UISelectBoolean Properties

UISelectMany Properties

UISelectOne Properties

UISelectItem Properties

UISelectItems Properties

Writing Properties Bound to Component Instances

Writing Properties Bound to Converters, Listeners, or Validators

Implementing an Event Listener

Implementing Value-Change Listeners

Implementing Action Listeners

Writing Backing Bean Methods

Writing a Method to Handle Navigation

Writing a Method to Handle an Action Event

Writing a Method to Perform Validation

Writing a Method to Handle a Value-Change Event

9.  Configuring JavaServer Faces Applications

Part III Web Services

10.  Introduction to Web Services

11.  Building Web Services with JAX-WS

12.  Building RESTful Web Services with JAX-RS and Jersey

Part IV Enterprise Beans

13.  Enterprise Beans

14.  Getting Started with Enterprise Beans

15.  Running the Enterprise Bean Examples

Part V Persistence

16.  Introduction to the Java Persistence API

17.  Running the Persistence Examples

18.  The Java Persistence Query Language

Part VI Security

19.  Introduction to Security in the Java EE Platform

20.  Using Java EE Security

21.  Securing Java EE Applications

22.  Securing Web Applications

Part VII Java EE Supporting Technologies

23.  Introduction to Java EE Supporting Technologies

24.  Transactions

25.  Resource Connections

Index

 

Bean Validation

A new feature, Bean Validation (JSR 303), is available in Java EE 6. A JSF 2.0 implementation must support Bean validation if the runtime (such as Java EE 6) requires Bean validation.

As you have seen in the example guessNumber application in the previous chapter, validation takes place at different layers in even the simplest of applications. The guessNumber application validates the UIInput component for numerical data at the presentation layer and for a valid range of numbers at the business layer.

Bean validation seeks to introduce a new model of validation which is applicable to all layers of application: presentation, business, or data.

The model is supported by validation constraints placed on a JavaBean class, field, get method, and so forth. A validation constraint is indicated by annotations placed on such class field, or method.

The following is an example of a constraint on placed on a field using the built-in @NotNull constraint:

public class Name { 
@NotNull 
private String firstname;  
@NotNull 
private String lastname;
}

The following is an example of a constraint placed on a method:

@Email 
 public String getEmailAddress() 
{
return emailAddress;
}

In the above case the constraint is user-defined. In such a case, the constraint also needs a validation implementation.

Bean validation is an advanced feature covered in more detail in Java EE 6 Tutorial, Volume II: Advanced Topics.