Richfaces

From Wikipedia, the free encyclopedia

RichFaces
Design by JBoss
Latest release 3.2.1 / [May 29, 2008]
Genre Ajax, Java, JSF, Framework
Website www.jboss.org


RichFaces is a rich component library for JavaServer Faces built on an advanced open source framework (Ajax4jsf). It allows easy integration of AJAX capabilities into enterprise-level business application development. RichFaces enriches the Ajax4jsf framework in two important ways. First, it expands a number of visual ready-to-use components. Secondly, it fully implements the skinnability feature of the Ajax4jsf framework including a large number of predefined skins. Using skinnability, it is much easier to manage the look-and-feel of an application.

Contents

[edit] History of RichFaces

RichFaces originated from Ajax4jsf framework which was created and designed by Alexander Smirnov. In early 2005, he was looking to add a “hot” new technology along with the associated experience to his resume. Roughly at the same time, the concept of AJAX was being introduced by Jesse James Garrett. Meanwhile, JSF was starting to pick up steam. Alexander figured why not just merge the two, so it would be easy to have AJAX functionality within a JSF application. He figured this would be an excellent addition to his resume. He started the project on sourcforge.net and called it Telamon (taken from the Shakespeare play, Anthony and Cleopatra). And, Ajax4jsf was born.

In the fall of that same year, Alexander joined Exadel and continued to develop the framework. Alexander’s goal was to create a tool that was easy to use and that could be used with any existing JSF component libraries.

The first version of what would become Ajax4jsf was released in March 2006. It wasn’t quite a standalone thing, yet. Rather, it was part of a product called Exadel Visual Component Platform. Later in the same year, Exadel VCP was split off and the Ajax4jsf framework and Rich Faces was born. While RichFaces provided out-of-the-box components or what’s called a component-centric AJAX approach (components do everything you need), Ajax4jsf provided what’s called page-wide AJAX support. You as a developer specify what parts of the page should be processed on server after some client side user actions and what parts should be updated after processing. Ajax4jsf became an open source project hosted on Java.net while RichFaces became a commercial JSF component library.

Fast-forward to March 2007. JBoss and Exadel sign a partnership where Ajax4jsf and RichFaces would now be under the JBoss umbrella and be called JBoss Ajax4js and JBoss RichFaces. RichFaces would now also be open source and free. In September 2007, JBoss and Exadel decided to recombine Ajax4jsf and RichFaces under the RichFaces name. It made sense as both libraries were now free, open source. Having just one product solved many version and compatibility issues that existed before, such as which version of Ajax4jsf works with what version of RichFaces?

While today you will still see an a4j namespace used, the product is now called JBoss RichFaces.

[edit] Framework

The framework is implemented as a component library which adds Ajax capability into existing pages, so you a developer doesn’t need to write any JavaScript code or to replace existing components with new Ajax widgets. RichFaces enables page-wide Ajax support instead of the traditional component-wide support. Hence, a developer can define the event on the page that invokes an Ajax request and the areas of the page that should be synchronized with the JSF Component Tree after the Ajax request changes the data on the server according to the events fired on the client.

RichFaces allows to define (by means of JSF tags) different parts of a JSF page you wish to update with an Ajax request and provide a few options to send Ajax requests to the server. Also JSF page doesn't change from a "regular" JSF page and you don't need to write any JavaScript or XMLHttpRequest objects by hands, everything is done automatically.


[edit] RichFaces Architecture

The architecture of RichFaces consists of Ajax Filter, AJAX Action Components, AJAX Containers, JavaScript Engine.

Ajax Filter - In order get all benefits of RichFaces, a developer should register a Filter in web.xml file of the application. The Filter recognizes multiple request types.
AJAX Action Components - AjaxCommandButton, AjaxCommandLink, AjaxPoll and AjaxSupport and other Action Components can be used to send Ajax requests from the client side.
AJAX Containers - AjaxContainer is an interface that describes an area on a JSF page that should be decoded during an Ajax request. AjaxViewRoot and AjaxRegion are implementations of this interface.
JavaScript Engine - RichFaces JavaScript Engine runs on the client-side. It updates different areas on a JSF page based on the information from the Ajax response. JavaScript Engine provides API so a developer doesn’t need to create own JavaScript functionality.

[edit] Skinnability

Skinnability is a special feature of RichFaces that is used for defining common interface styles. The feature is based on XCSS technology which provides flexibility and dynamics. RichFaces provide a set of predefined skins:

  • DEFAULT
  • plain
  • emeraldTown
  • blueSky
  • wine
  • japanCherry
  • ruby
  • classic
  • deepMarine

Skin properties, such as, generalBackgroundColor, generalLinkColor, headerFamilyFont etc are stored in skinname.skin.properties file. While each component has a XCSS (a special file format that combines flexibility of XML and CSS) file that performs mapping of CSS selectors to the skin properties of a particular skin. Additionally, RichFaces provides skinning for standard HTML controls. In the latest version of RichFaces a new feature Plug-n-Skin was introduced, it’s used for easy custom skin creation.


[edit] Simple JSF page with RichFaces calender component

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:a4j="http://richfaces.org/a4j"
        xmlns:rich="http://richfaces.org/rich">
        <ui:composition template="/templates/component-sample.xhtml">
                <a4j:outputPanel id="calendar" layout="block">
                        <rich:calendar value="#{calendarBean.selectedDate}"
                        locale="#{calendarBean.locale}"
                        popup="#{calendarBean.popup}"
                        datePattern="#{calendarBean.pattern}"
                        showApplyButton="#{calendarBean.showApply}" cellWidth="24px" cellHeight="22px" style="width:200px"/>                     
                        </a4j:outputPanel>
 
 
        </ui:composition>
</html>

This is the result of the presented above code.
Image:RichFacesCalendar.png‎


[edit] References