Java Server Faces is an MVC based framework to design User Interface for Server Side Technologies. We can use UI widgets in server based event handlers. The Java Servlet container is used to run these applications. JSF provides core libraries, UI components and many more extended features to create a well defined UI for Web server applications. In crux, JSF or Java Server Faces is a standard technology which is highly used in the Java Developers Community.
Java Server Faces Architecture
JSF architecture is based on the MVC (Model View Controller) architecture. UI Components can be rendered in many ways like Computing Device, HTML browser etc. The diagram for the JSF architecture is shown as follows.
Advantages of JSF
JSF is highly advantageous due to the following reasons:
- Presence of Reusable UI components
- JSF manages multiple server requests at a time
- Multiple Custom components can be used by implementing JSF
- Simple and Easy to maintain
Lifecycle of JSF
JSF lifecycle contains 6 phases as mentioned in the figure below.
Steps to create a simple JSF application:
The basic requirement is to install the archetype-webapp plugin. The step by step implementation in given below for Windows Operating System using Eclipse IDE.
- Open command prompt (cmd) to set the path for JSF application
- use the command: mvn archetype:create to initiate mavern
- Add the JSF capability to the project. Also add all the JSF dependencies to the project.
- Open Eclipse IDE and create a new Java project
- Import the project created earlier using JSF capability using import button in Eclipse
- Configure the Faces Servlet in web.xml file of the project created in Eclipse
- Create a Managed Bean for the given package of the java program
- Create a JSF page under the web app directory in Eclipse IDE.
- Build the project and run it as an maven package
- Deploy WAR file, run the a wizard project and start the tomcat server.
- Run the complete application using the run command, which will launch the application on the server