Java Server Faces Model/View/Controller Design Pattern for Web Development Slides adapted from “Core JavaServer Faces” by Geary and Horstmann and the J2EE Tutorial from Sun Microsystems
Three main parts to JSF A Collection of GUI components An event driven programming model A component model supporting third party component development
Detailed Features of JSF Bean management Validation model Component library that permits extensions Flexible rendering (not necessarily XHTML) Configurable navigation State management Conversion Model Relies on JSP and Servlet technology Think “GUI Building” for the web
JSF Fundamentals Tags correspond to components in a component tree A request normally goes through several stages of processing on the server A built-in FacesServlet handles request processing and the JSF life cycle
JSF Life Cycle Overview (From the J2EE Tutorial)
Restore an old or construct a new component page (or view)
An old view (component tree) has been retrieved so allow each component in the view to inspect data values. These values will be redisplayed if validation or conversion errors are found. Adds events to an event queue.
The submitted values are stored as “local values”. If the data is invalid or conversions are not possible then Render Response is called directly and the user sees the bad data.
Local values are OK and are used to update the beans.
The action method associated with the button or link that caused the form to be submitted is executed. The method returns a string for the navigation handler. The navigation handler uses the string to determine the next page.
The selected page is rendered into a markup language.
Some Really Simple Examples