Over a million developers have joined DZone.

ICEFaces 2.0 And JSF 2.0 Together

· Java Zone

Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management, brought to you in partnership with Stormpath.

JSF Ajax frameworks have been around for some time. JSF is all about server side components that render their state as markup to the client. JSF has a well defined lifecycle that defines how component state is handled on the server and when component state is rendered to the client.  JSF Ajax frameworks can control which components are processed on the server (known as partial processing), and which components render themselves back to the client (known as partial rendering) by sending Ajax requests with special parameters. 

How ICEFaces Uses JSF 2.0  To Send Ajax Requests

The JSF 2.0 Ajax JavaScript API jsf.ajax.request can be used to trigger Ajax requests from an HTML event such as onclick.  This function can be called from within a JavaScript function too.  ICEFaces uses the jsf.ajax.request function within their JavaScript library:

    submitEvent = function(event, element, form) {
jsf.ajax.request(element, event, {execute: '@all', render: '@all'});

submitForm = function(event, form) {
jsf.ajax.request(form, event, {execute: '@all', render: '@all'});


ICEFaces uses submitEvent and submitForm in their iceSubmitPartial and iceSubmit functions respectively.  The iceSubmitPartial and iceSubmit functions are part of the ICEFaces Ajax Bridge that  communicate with the server.  ICEFaces is using the keyword @all for both execute and render which means that all components are processed on the server, and all components are targeted for rendering markup back to the client.  ICEFaces sends everything because on the server the framework determines the "dirty" regions in a view by comparing the current rendered view with the view that was rendered as a result of the Ajax request.

How ICEFaces Uses JSF 2.0 To Process Ajax Requests On The Server

JSF 2.0 provides extensibility points that allow JSF Ajax frameworks to perform customized partial processing and partial rendering on the server.  The JSF 2.0 API provides the javax.faces.context.PartialViewContext.processPartial method for this purpose.  This method performs partial processing and partial rendering on the components identified by the identifiers in the execute and render lists from the request.  ICEFaces extends javax.faces.context.PartialViewContext with their DOMPartialViewContext impementation:


import javax.faces.context.PartialViewContextWrapper;
public class DOMPartialViewContext extends PartialViewContextWrapper {
public void processPartial(PhaseId phaseId) {
if (isRenderAll() && PhaseId.RENDER_RESPONSE) {
// Perform DOM Diffing ..
// Send updates as separate <update> elements using JSF 2.0 PartialResponseWriter
} else {


If the current processing phase is the Render Response Phase, ICEFaces:
  • retrieves the current DOM (for the view before rendering)
  • generates the new DOM by rendering the new view (using a special DOMResponseWriter)
  • determines if there are differences between the DOMs


If there are differences, then the JSF 2.0 javax.faces.context.PartialResponseWriter implementation is used to write <update> elements back to the client following the specification defined partial response format:

<update id="user">
<update id="password">

If there are no differences, then the JSF 2.0 javax.faces.context.PartialResponseWriter implementation is used to write the single <update> element containing the entire view markup.


ICEFaces 2.0 is still under development, and it is one of the early component frameworks that follow the JSF 2.0 Ajax standard.  It uses the JSF 2.0 Ajax JavaScript API to initiate Ajax requests to the server.  It leverages the JSF 2.0 Ajax extensibility points on the server to process Ajax Requests and formulate the partial response to send back to the client.  This version of ICEFaces (2.0) currently uses the mojarra  implementation of the JSF 2.0 specification.  There will surely be more component frameworks on board with JSF 2.0, which should go a long way towards component interoperability.


ICEFaces 2.0
JavaServer Faces 2.0 Specification
Project Mojarra

Building Identity Management, including authentication and authorization? Try Stormpath! Our REST API and robust Java SDK support can eliminate your security risk and can be implemented in minutes. Sign up, and never build auth again!


Published at DZone with permission of Roger Kitain. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}