JavaServer Faces Libraries
JavaServer Faces is a standardized specification for building User Interfaces for server-side applications. There are two main JSF implementations, both open -source namely:
- Sun Mojarra – reference implementation provided by Oracle. Jars include jsf-api.jar and jsf-impl.jar.
- Apache MyFaces – Jars include myfaces-api.jar and myfaces-impl.jar.
- Any other Java EE 6 server, as JSF 2.0 has become an official part of Java EE 6 platform. examples of supported Java EE 6 servers being JBoss 6, Weblogic 11g, WebSphere 8, tec.
Like any other specification, JSF has gone through various iterations in the form of versions starting with version 1.0 all the way up to version 2.1 at the time of writing this book. There have been many releases of version 1.1 and 1.2 at various stages more concentrated on bug fixing.
There are many component libraries in market for JSF. Some of them are as summarized below:
- JBoss RichFaces
- Oracle ADF Faces
Configuring JSF application is as simple following the steps as described below in bulleted format for better reading:
- Include the JSF implementation libraries in your web application
- Configure the FacesServlet provided by the JSF implementation. It acts as the FronController servlet for your JSF application and is typically mapped by extensions similar to *.faces etc. This servlet is responsible for driving the JSF lifecycle as a whole.
- Rest or almost all of the configurations is done through the use of faces-config.xml file. This configuration file was quite verbose in JSF version 1.2 but JSF version 2.x brought in lot of implications using Java annotation.
Why JavaServer Faces?
You might be asking the question, so why JSF? There are so many web frameworks available in market and some are really good but with lack of marketing. Why should we go with developing web application based on JSF? The answer to this question can be summarized below by giving the benefits which JSF technology provides:
- Built on standard JSF specification. Huge vendor and industry support. This means that you can expect good level of support and quality components from these vendors.
- JSF brings in clean separation between behavior and presentation which inherently brings simplicity in design. This will intern bring in clean separation between various roles in an organization.
- Provides rich and concrete architecture for managing component state, processing data, validating input and handling events. The concept of validator and converters are really helpful and useful.
- Very robust event handling mechanism similar to thick client applications which have is important in any modern day web application having rich look and feel.
- Support of different client rendering by the use of different render kits.
- Key factor that JSF is highly pluggable in nature supporting plugging in third-party components, view handlers etc. making it really extensible in nature.
- JSF has very good support for expression language (EL) support which will improves the user interface code readability to a greater extent.
Disadvantages of JSF
Having said some rosy picture about JSF, let’s now delve into not so rosy picture about JSF. They can be summarized briefly as shown below:
- There are so many third-party component libraries but they don’t generally work together. Simply put they don’t mix in an application.
- Customizing a component provided by the component library can be quite a task in itself.
- Heavy usage of HTTP session can put lot of strain on the server resources and as the application grows can be potentially threatening to some extent. High performance application can suffer because of high footprint of server resources.
- Some very common web requirements like URL design, bookmarking etc. can be harder to implement and put more work on the developers implementing these requirements.
- Applications requiring dynamic component rendering like adding and removing component based on business case can be hard to implement.
- Default error messages are not so good.
- Comparatively with respect to other web frameworks, learning curve is higher. Not so helpful and good documentation makes it more stressful to developers.
- Compared other frameworks, there are so much going on behind the scenes making it harder for developers to debug and drill to the root cause.
I haven’t covered nitty-gritties of each component and its flaws as it can be quite cumbersome to understand at this point in time. But there exists specific disadvantages associated with certain component implementation which can make developers unhappy.
JSF vs. Struts
JSF has more advantages compared to programming web application using JSP along with Servlets and Struts. But it’s worthwhile knowing that Struts and JSF can co-exists in a well application. Compared to JSF, Struts has following disadvantages as summarized below:
- Struts don’t have built-in event model for UI components.
- Struts don’t have built-in UI component model.
- Struts don’t have built-in state management for UI components.
- Struts don’t have built-in support for multiple renderers. Struts is limited to HTML and HTTP.
- Above all, Struts is not a standard. Vendor and tool support less as compared to JSF.
JSF 2.0 is the first major revision since the original standard designed way back in 2004. Standard was completed in summer 2009 and implementation from Sun Mojarra released in October 2009 and Apache MyFaces in April 2010. Major improvement brought in many areas, some of well know ones can be summarized as shown below:
- Ajax has become a standard way of doing things.
- Rendering capability using Facelets and it has been built into the standard.
- New State using view/flash scopes.
- Configuration support using annotations bringing in simplicity and configuration ease.
- JSR-303 validation support
- Support for GET and bookmarkability.
- Navigations based on conventions.
Page Visitors: 2876