JavaServer Faces (JSF) Overview


In short, JSF is a UI component framework for J2EE applications.

Component Model
We will see an improvement in productivity with JSF using UI components that hide most of the grunt work of integrating richer functionality into Web applications. The goal is to provide an easy way to construct UIs from a set of reusable UI components. We can use these components to construct a page and nest UI components within each other to get the desired effect.
This structure of nested components is often referred to as a parent-to-child relationship and visualized as a UI component hierarchy. This UI component hierarchy represents a JSF page description at runtime.

Navigation Model
JSF provides a declarative navigation model, which allows application developers to set navigation rules to define the navigation from one view to another in a Web application. 
Navigation rules in JSF are defined inside the JSF configuration file, faces-config.xml, and are page-based. 

This code shows a navigation rule configured in faces-config.xml :

<navigation-rule>
<from-view-id>/login.jspx</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/result.jspx</to-view-id>
</navigation-case>
</navigation-rule>

From a view, login.jspx, on an outcome of success, the user will be sent to a page called result.jspx. 
The outcome is the return value from an action performed in the application such as a button being clicked. 

Application Lifecycle
Another benefit that application developers will discover when using JSF is that the framework helps manage UI state across server requests. 
Instead of having to take care of user selections and passing these selections from page to page, the framework will handle this for you. 
The JSF framework also has built-in processes in the lifecycle to assist with validation, conversion, and model updates.