JavaServer Faces technology is a server-side component framework for building Java technology based web applications. JavaServer Faces technology is built on top of Java Servlet technology and provides a well-defined programming model API and various tag libraries.
The JavaServer Faces API is used for represents components and managing their state, server-side validation, event handling, data conversion, defining page navigation and for supporting internationalization
JavaServer Faces technology provides Tag Libraries for adding components to web pages and for connecting components to server-side objects.
JavaServer Faces technology provides a clean separation of presentation and behavior for Java technology based web applications.
JavaServer Faces leverages existing Java based server technologies. JavaServer Faces technology is built on top the familiar Java Servlet technology.
JavaServer Faces technology does not force you to use a particular scripting technology or markup language. You can use existing Java scripting languages such as JSTL.
Java ServerFaces components form the building blocks of a JavaServerFaces view. A component may be a UI component or a non-UI component.
JavaServer Faces's component architecture provides the following features.
Component Behavior - A set of javax.faces.component.UIComponent classes for specifying the state and behavior of UI components.
Component Rendering - A rendering model that defines how to render the components in various ways
Conversion Model - A conversion model that defines how to register data converters onto a component
Event and Listener ModelAn event and listener model that defines how to handle component events.
Validation Model - A validation model that defines how to register validators onto a component
JavaServer Faces technology architecture separates component functional logic from its rendering logic by delegating the rendering functionality to separate renderer classes and packaging them in a render kit.
A render kit defines how component classes map to component tags that are appropriate for a particular client.
The render kit defines a set of javax.faces.render.Renderer classes for each component that it supports. Each Renderer class defines a different way to render the particular component to the output defined by the render kit.
JavaServer Faces technology architecture provides the option of linking a component to a managed Java bean object. The application sets and gets the data on the Java bean object
When a component is bound to a Java bean, then the component has two views.
1. The model view,in which data is represented with primitive data types such as int or double.
2. The presentation view, in which the data is formatted to render to the clievet view.
The JavaServer Faces implementation automatically converts the component's data between these two views.
JavaServer Faces technology provides a flexible navigation model which makes it easy to define the sequence in which the pages are loaded.
User defined navigation rules can be defined in one or more application configuraton resoirce files.
The JavaServer Faces event and listener model has strongly typed event and listener interfaces that an application can use to handle events generated by components.
The JavaServer Faces defines three kinds of events - application events, system events, data-model events
Application Events - Application events are tied to a application and are generated by component of type UIComponent
System Events - System events are generated by Java objects of type Object and not by UIComponent and apply to the entire application rather than to a specific component.
Data-model event - A data model event occurs when a new row of a UIData component is selected.
The JavaServer Faces technology provides a mechanism of validating data of editable components such as text fields and text areas.
The JavaServer Faces technology provides a set of in-built standard classes that perform common data validation checks.
A validator can be registered on a component by nesting the validator's tag within the components tag.
A standard JavaServer Faces application goes through the following sequence of events
1. Restore View - Builds view of the page, wires event handlers and validators to components of the view, saves the view in FacesContext instance.
2. Apply Request values - In this phase the components of the tree view are updated with their new values from the request.
3. Process validations - In this phase, all validation registered on the components are processed.
4. Update model values -
6. Invoke Application -
10. Render Response
Facelets, a part of JavaServer Faces technology, is the preferred presentation technology for building JavaServer Faces technology based web applications. Facelets is a lightweight page declaration language that is used to build JavaServer Faces views and to build component trees.
A JavaServer Faces application has to be configured in two locations.
1. Map the JavaFaces servlet in web deployment desc.
2. Add bean definitions, navigation rules and resource bundle declarations to application configuration resource file faces-config.xml.
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
The JavaServer Faces technology provides templates that act as a base or template for other pages.
Templating enables code reuse, enables a constant look and feel for the application and prevents construction of multiple similar pages.
The JavaServer Faces technology provides templates that act as a base or template for other pages.
Templating enables code reuse, enables a constant look and feel for the application and prevents construction of multiple similar pages.
The JavServer Faces web pages refer to following two standard tag libraries.
1. The JavaServer Faces HTML render kit tag library - this tag library defines tags that represent common HTML user interface components.
2. The JavaServer Faces core tag library - this library defines tags that represent core actions
The JavServer Faces web pages refer to following two standard tag libraries.
1. The JavaServer Faces HTML render kit tag library - this tag library defines tags that represent common HTML user interface components.
2. The JavaServer Faces core tag library - this library defines tags that represent core actions
The JavServer Faces web pages refer to following two standard tag libraries.
1. The JavaServer Faces HTML render kit tag library - this tag library defines tags that represent common HTML user interface components.
2. The JavaServer Faces core tag library - this library defines tags that represent core actions
The JavServer Faces web pages refer to following two standard tag libraries.
1. The JavaServer Faces HTML render kit tag library - this tag library defines tags that represent common HTML user interface components.
2. The JavaServer Faces core tag library - this library defines tags that represent core actions