Skip to content

JSF Architecture in Java

JSF Architecture in java

Exploration of JSF Architecture

Similar to most of the popular Web application frameworks, JSF(JavaServer Faces) implements MVC design pattern. The implementation of the MVC design pattern helps to design different components separately and each of these components implements different types of logic, For example, you can create a view component for presentation logic and model component for business logic implementation. A controller is another component, which controls the execution of various model methods and navigates from one view to another in a Web application.

MVC Design Pattern

(Figure.  MVC Design Pattern)

The controller part of the JSF architecture consists of a Controller Servlet, that is, FacesServlet, a centralized configuration file, faces-config.xml, and a set of event handlers for the Web application. The Front Controller Servlet receives all the requests and manages the request processing life cycle of each request to generate a response for the client. In JSF, the FacesServlet is a Servlet that is responsible to manage the request processing life cycle of the Web application and is also used by JSF to design the user interface. Every JSF application contains the web.xml file which specifies a Java Servlet of type FacesServlet. The application settings are also configured in FacesServlet through which all requests are channeled. On the basis of the results of component events, the flow of an application’s pages is also controlled by the FacesServlet. This process of handling the flow of pages is represented in the Front Controller design pattern.

The FacesServlet also manages client requests by referencing the page mappings provided in the faces-config.xml configuration file. This configuration file contains a number of JSF configurations. Event Listeners respond to component events, which perform some processing and generate an outcome that can be used FacesServlet.

MVC Architecture of JavaServer Faces

(Figure.  MVC Architecture of JavaServer Faces)

The Model in JSF architecture is a set of server-side JavaBeans that retrieves the values from the model components, such as the database and define methods on the basis of these values. These JavaBeans may further persist in a database through an underlying persistence layer. This layer may include Java Data Objects, Enterprise JavaBeans, or an Object-Relational Mapping implementation, such as hibernate. The view in JSF architecture comprises stateful Ul components.

The UI Components are rendered in different ways according to the type of the client. The view delegates this task to separate the renderers, each taking care of one specific output type, such as HTML or Wireless Markup Language (WML). You can also attach various additional delegates such as validators and converters to specific components. Converters are used to validate and convert the values entered by the user. The client always submits strings as values for input fields that may need to be converted to a numerical data type, if the string values have to be used in a calculation Validators check if the values delivered by the client is syntactically correct or are according to a specified format. The view also features resources, which may be used for localization of the Web application.

Learn more about JSF Life Cycle.

nv-author-image

Era Innovator

Era Innovator is a growing Technical Information Provider and a Web and App development company in India that offers clients ceaseless experience. Here you can find all the latest Tech related content which will help you in your daily needs.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.