Book Image

Mastering JavaServer Faces 2.2

By : Anghel Leonard
Book Image

Mastering JavaServer Faces 2.2

By: Anghel Leonard

Overview of this book

Table of Contents (20 chapters)
Mastering JavaServer Faces 2.2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
The JSF Life Cycle
Index

Configuring system event listeners


JSF 2.0 allows us to use system events. These are events that can be fired by arbitrary objects at arbitrary points during the request processing lifecycle. Since the number of these events is quite big, you will not see them entirely covered here, but the next five examples should clarify the basic aspects of system events. You can find all of them in the javax.faces.event package.

Using <f:event>

The easiest way to use system event listeners consists in passing the name of the managed bean method in the listener attribute of the <f:event> tag. For example, PostValidateEvent is a system event that gets fired after all components are validated. This can be useful to validate multiple components. Suppose, that a user submits a form that contains his name, surname, bank account, and the confirmation of that bank account (like a password that should be typed twice for confirmation). In order to check if the same bank account was typed in both fields...