|
Developing Web Interfaces with JSF (Continued)
Requests and Responses
In general, a JSF application supports two kinds of requests and responses. A faces request is sent from a JSF page, such as a form submitted from a page using JSF UI components. A faces response originates from a JSF application, which is the JSF "render response" phase of the request-processing life cycle. A non-faces request is sent to non-JSF application components, such as a plain servlet or a non-JSF JSP. A non-faces response is not created by the execution of the render response phase—for example, a response from a JSP that does not use JSF components.
How JSF executes depends on the scenario. For example, when a non-faces request generates a faces response (perhaps when you first access a faces application), a certain set of activities occurs for the first time, such as creating a new faces view, storing it in the faces context, and then executing a faces response. This faces view contains a run-time UI component tree and will be referred to in future requests.
When a future faces request is received, the existing view or component tree in the faces context is reconstituted and the new request values are applied. Subsequent events and/or validations are processed, and corresponding faces responses are executed (see Figure 1).
The main point about the life-cycle processing of a JSF application is that with JSF there is a managed component tree that constantly represents the UI—in contrast to the typical stateless Web application. This characteristic gives JSF applications the ability to handle events and state changes in the same manner a traditional, thick-client Java application would.
Similarly to Java client applications, JSF provides a rich library of UI components that is fully configurable and can be used in many ways. JSF UI components essentially are Java classes that perform distinct Web application-related functions. A UI component can be rendered in different ways. For example, the UICommand component can be rendered as either a URL link or a form button. JSF UI components come with a preexisting set of renderers, but building your own renderers, as well as your own custom components, is also possible.
So how does one use a specific UI component with a specific renderer? JSF provides JSP tag libraries for handling default usages of the UI components. When using the provided JSF JSP tags, a UI component class is coupled with a specific renderer and executed to display a component to the client. JSF's library of JSP component tags provides useful combinations of UI component classes and component renderers. For example, to use the UI component UICommand, Web application developers can use either the command_button tag or the command_link tag, depending on how they want the command to render. See Table 1 for examples of UI components and renderers.
JSF developers aren't limited to the core components that come with the JSF API. When needed, developers can use the JSF API to extend or create new, custom UI components that are more suited to specific needs. Because of this extensibility, JSF architects envision that many independent developers will provide custom JSF components to share with the Java community in the same way JSP tag libraries or other components are shared now.
Back to top
|