JavaServer Faces - A basic walk through


In this article, I am giving a basic introduction to a widely used framework in Java called JSF to naive audiences and how they can get started in building a rich user interface in their web applications.

An introduction to JSF


JSF(JavaServer Faces) is a recently originated framework by Sun Microsystems based in Java. A standard developed by JCP (java community process), it holds compliance to any application Server in Java EE such as GlassFish, Jboss or Oracle's Weblogic. It is meant for designing and building rich web applications. It makes the work simple for programmers/web developers as it provides an approach which is component-centric and supports listeners on the front end components. It facilitates the development of extensive web user-interfaces and is now an industry accepted standard for building user interfaces on the server side in Java EE.

For front end and corporate developers, building user interfaces in JSF is as simple as dragging and dropping components onto a page. System developers are fond of it as the robust and rich API exposed by JSF provides them a great deal of flexibility in programming and unsurpassed power by using the well established and reliable MVC (model-view-controller) design pattern as a core ingredient architecture. JSF is an independent stand alone framework for web which can also be paired up with bean containers like Spring framework. Applications that use JSF can be created, without having to add other external dependencies or libraries in the project.

JSF with Ajax


JavaServer Faces is a component-based design model for front end. It uses XML files, which are referred to as Facelets views. Any server side request is processed by FacesServlet. It directs to the view template which is the most appropriate with respect to the request, builds up a component tree, performs actions on events and sends response at the client side (typically as HTML). The components of user interface save their state with every request, and it is restored at the next instance of time when the view is created. JSF can render output in multiple formats and hence can be used in conjunction with Ajax to develop rich internet applications. JSF 2.0 has built-in support for Ajax and has simplified the development process.

Configuration files


The configuration files needed for setting up a JSF application are :

web.xml: It is the general configuration file located in the WEB-INF directory for any web application. A FacesServlet must be defined in this file which is the core controller and will be responsible for handling the flow of JSF application.

Also Read: Getting familiar with design patterns in Java

faces-config.xml: Application, managed beans, convertors to map UI input to back end model, navigation flow between web pages and UI input validators are configured in this file.

Why is JSF preferred to struts


Javaserver Faces is a more commonly used framework as compared to struts because it has an extensible and a flexible UI component-based model which has an extensive range of components, both simple and complex and an API that specifies how a component can be rendered in different ways. It allows developers to create their own custom components too. Secondly, it supports a event-and-listener model that specifies handling of events that are triggered when the component(s) are activated. Also, it can validate the component data and map it to the model.


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: