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

JSF 2.2 programmatic configuration


Starting with JSF 2.2, we can programmatically reproduce the content and tasks of faces-config.xml. The starting point consists of a callback method, named populateApplicationConfiguration, which gets a single argument of type org.w3c.dom.Document—this class belongs to DOM API. Basically, a Document (tree node) is a representation in memory of an XML document, and we can manipulate it by adding, removing, importing, or adopting nodes, elements, and text. For each of these operations, there are dedicated methods. For some JSF developers, this API can be something new that should be learned; therefore, this can be a drawback of programmatic configuration.

For now, let's resume the dissertation from the callback method. The populateApplicationConfiguration method is provided by a class that extends and implements the abstract class ApplicationConfigurationPopulator found in the javax.faces.application package. In order to tell JSF about this class, you need...