JBoss.orgCommunity Documentation
Read this chapter for technical details on the RichFaces framework.
RichFaces has been developed with an open architecture to be compatible with a wide variety of environments.
RichFaces 4 requires either of the following server technologies:
An application server compliant with Java Platform, Enterprise Edition 6 (JEE6 or JEE6), such as JBoss Application Server 7.
A major servlet container, such as Jetty 8 or Apache Tomcat 7.
Clients accessing RichFaces applications require a web browser. RichFaces supports the following web browsers:
Microsoft Windows environments
Firefox 3.6 or Firefox 7.0 and higher
Google Chrome 14 and higher
Internet Explorer 8.0 and higher
Other browsers and versions are partially supported.
Developing applications with the RichFaces framework requires the Java Development Kit (JDK), an implementation of JavaServer Faces (JSF), and a development environment.
RichFaces supports the following JDK versions:
JDK 1.6 and higher
RichFaces supports the following JSF implementations and frameworks:
MyFaces 2.x
Seam 3.x
Mojara 2.x
RichFaces can be developed using most Java development environments. The following are recommended, and used for examples in this guide:
JBoss Tools 3.3 and higher
Maven 3.0.3 and higher
The important elements of the RichFaces framework are as follows:
Ajax Action Components
Ajax Containers
Ajax Output
Skins and Theming
RichFaces Ajax Extensions
Read this section for details on each element.
The RichFaces framework includes several Ajax Action Components and Submitting Bahaviors: <a4j:commandButton>
, <a4j:commandLink>
, <a4j:poll>
, <a4j:ajax>
, and more. Use Ajax Action Components to send Ajax requests from the client side.
AjaxContainer
is an interface that marks part of the JSF tree that is decoded during an Ajax request. It only marks the JSF tree if the component or behavior sending the request does not explicitly specify an alternative. AjaxRegion
is an implementation of this interface.
AjaxContainer
is an interface that marks part of the JSF tree that will be updated and rendered on the client for every Ajax request. It only marks the JSF tree if the component or behavior sending the request does not explicitly turn off automatic updates.
RichFaces includes extensive support for application skinning. Skinning is a high-level extension to traditional CSS (Cascading Style Sheets) which allows the color scheme and appearance of an application to be easily managed. The skins simplify look-and-feel design by allowing multiple elements of the interface to be handled as manageable features, which have associated color palettes and styling. Application skins can additionally be changed on the fly during run-time, allowing user experiences to be personalized and customized.
For full details on skinning and how to create skins for the components in your application, refer to Chapter 6, Skinning and theming.
RichFaces 4 features full JSF 2 integration and uses standard web application technologies such as JavaScript, XML (Extensible Markup Language), and XHTML (Extensible Hypertext Markup Language).
JavaServer Faces 2 evaluates Ajax options, such as execute
and render
, while rendering a page. This allows any parameters to be sent directly from the client side.
RichFaces evaluates the options when the current request is sent. This increases both the security of the data and the convenience for evaluating parameters.
For example, binding Ajax options to Java Bean properties in RichFaces allows you to evaluate the options dynamically for the current request, such as defining additional zones to render. Parameters changed manually on the client side will not influence the request processing. With JSF 2, the options have evaluated during the previous page rendering would need to be used.
The following restrictions apply to applications implementing the RichFaces framework:
As with most Ajax frameworks, you should not attempt to append or delete elements on a page using RichFaces Ajax, but should instead replace them. As such, elements that are rendered conditionally should not be targeted in the render
attributes for Ajax controls. For successful updates, an element with the same identifier as in the response must exist on the page. If it is necessary to append code to a page, include a placeholder for it (an empty element).
JSF 2 does not allow resources such as JavaScript or Cascading Style Sheets (CSS) to be added if the element requiring the resource is not initially present in the JSF tree. As such, components added to the tree via Ajax must have any required resources already loaded. In RichFaces, any components added to the JSF tree should have components with corresponding resources included on the main page initially. To facilitate this, components can use the rendered="false"
setting to not be rendered on the page.
JSF does render resource links (stylesheets, scripts) in order of occurence, thus if you add <h:outputStylesheet>
to the <h:head>
section, JSF will render it before the RichFaces resource links (dependencies of RichFaces components). To be able to overwrite RichFaces stylesheets and re-use RichFaces JavaScript implementation, you need to render <h:outputStylesheet target="head">
to the <h:body>
section (safe solution is to place it on the end of the section; however to keep readability, you can use start of the section).
Switching RichFaces skins via Ajax during runtime should be avoided, as this requires all the stylesheets to be reloaded.