Introducing Java Server Faces (JSF) (Page 1 of 4 )
The event driven paradigm has been considered the forte of desktop applications for a long time. Though web applications have HTML to present the user with buttons and other familiar GUI elements, the developer has to work with the request-response paradigm. However, server-side development is slowly shifting towards the event driven paradigm. Frameworks are accelerating this shift by abstracting out the difficulties of constructing an event-handling layer over a request-response layer.
In the context of J2EE or JEE, the framework that is providing an event-based development platform is Java Server Faces, or JSF as it is popularly known. In this discussion I will be focusing on the basics of JSF. The first and second sections will cover the terminology associated with JSF. In the third section, I will enumerate the steps required for setting up the arena for JSF. In the last section I will implement a real world solution using JSF. That outlines the agenda for this discussion.
JSF: Understanding the Terminology
Whenever a new framework comes into being, it brings a plethora of new terms and vocabulary with it. JSF doesn't contradict this generalization. However, in the case of JSF, its terminology is also its components. In other words, one cannot develop using JSF without understanding the terms, because they are the pieces of the puzzle called JSF. The following are the main components that make JSF:
Events and Listeners
If you observe carefully, you will see that the first, fourth and sixth components are present in one form or another while working with any event driven toolkit, but the second, third and fifth are additions to JSF. The seventh and eighth are the demands of any web framework. Here are the details.
UI Components are also known as controls or simply components. A component is a stateful object. It is built atop JavaBeans. In other words, a UI Component has properties, events and methods. The obvious question here is, what is the difference between a JSF UI Component and a Swing component? The answer is that JSF UI Components have been chosen with server side constraints in mind, and these components live on server-side not on the client side.
The other important thing to keep in mind is that web applications can never be built using components. The components themselves are not shown on the client-side, but they output the HTML which is then interpreted by the browser and shown to the user as GUI elements. In other words, the UI Components are rendered for the browser. A UI Component can be represented in many ways. How it is shown is decided by Renderer.
A component cannot render itself. It is the responsibility of the Renderer to display the component and translate the user input values into the values understandable by the component. A single Renderer can work with multiple components, and a component can work with many Renderers. In short, UI Components and Renderers have a many-to-many relationship. A Renderer can be thought of as a translator between the client and the server. The main thing to keep in mind about Renderers is that custom renderers can be hooked to existing UI Components.