This chapter has been leading us gently through the JavaServer Faces technology. More importantly, in it, Budi teaches ushow to write an online survey application to get a feel for how this great technology works. This chapter prepares you for the next chapters by introducing the JSF Application Programming Interface (API) and the Application Configuration file. This excerpt comes from chapter two of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).
The javax.faces.lifecycle Package The javax.faces.lifecycle package contains classes and an interface that have something to do with the request processing lifecycle. There are two classes in this package: Lifecycle and LifecycleFactory. As explained earlier in this chapter, the Lifecycle object is the object that processes a JSF request. The Lifecycle object is represented by the javax.faces.lifecycle.Lifecycle class. The LifecycleFactory class is responsible for creating a Lifecycle instance.
The only interface in this package is ViewHandler. This interface defines a mechanism by which the Render Response phase of the request processing lifecycle can support different response-generation technologies.
The javax.faces.render Package The javax.faces.render package contains three classes: Renderer, RenderKit, and RenderKitFactory. A Renderer is responsible for converting the internal representation of a UI component into something that is understood by the JSF client. When JSF is used in a Web application, a Renderer sends HTML tags to the browser as the representation of a UI componentís state. A Renderer normally can render one UI component, so there are always many Renderer objects for the various standard UI components used in a JSF application.
A RenderKit represents a collection of Renderer instances. The JSF implementation comes with the default RenderKit.The RenderKitFactory is a factory object that returns a RenderKit instance.
Renderers are discussed in Chapter 12.
The javax.faces.tree Package The javax.faces.tree package contains the Tree and TreeFactory classes. The Tree class represents a component tree. The TreeFactory is responsible for creating Tree instances.
The javax.faces.validator Package The javax.faces.validator package contains the Validator interface that you implement to write your custom validator. It also contains a number of standard validator classes: DoubleRangeValidator, LengthValidator, LongRangeValidator, RequiredValidator, and StringRangeValidator. Validators and input validation are discussed in Chapter 9.
The javax.faces.webapp Package The members of the javax.faces.webapp package are classes that are required for integrating JSF into Web applications. The most important class in this package is the FacesServlet class. An instance of this class is required by each JSF application to manage the request processing lifecycle. Its job description includes obtaining a FacesContext instance and passing it to the Lifecycle object for processing.
Another member, UIComponentTag, is a base class that you need to extend to create a tag handler that handles a JSP custom action that is related to a UI component. You can see this class used in Chapters 12 and 13.
Summary This chapter provided a gentle introduction to JSF. Its main objective was to give you the experience of running your first JSF applications. You got an idea of how JSF works, without going into all of the details yet. You will learn more about JSF processing in later chapters.
In this chapter, you learned the most important characteristic of JSF applications that makes them different from other servlet/JSP applications: their event-driven nature. You also built three simple JSF applications that illustrate the component tree, event processing, input validation, and page navigation. The last section of this chapter offered a general overview of the JSF API, which you will be using to develop JSF components in the next chapters.
Remember: This is part three of the second chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). If you've enjoyed what you've seen here, click on the "Buy it now!" banner to pick up a copy today! Buy this book!