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

Combined power of multiple factories


In the last several sections, you saw how to customize and configure the most used JSF factories. In the final section of this chapter, you will see how to exploit a few factories in the same application. For example, a convenient scenario will assume that we want to fire a non-JSF request and get as response a JSF view. An approach of this scenario consists in writing a Java Servlet capable of converting a non-JSF request into a JSF view.

In order to write such a Servlet, we need to obtain access to FacesContext. For this, we can combine the power of the default LifecycleFactory class with the power of the default FacesContextFactory class. Further, we can access Application via FacesContext, which means that we can obtain the ViewHandler that is responsible for creating JSF views via the createView method. Once the view is created, all we need to do is to set UIViewRoot and tell Lifecycle to render the response (execute the Render Response phase). In...