The Source for Java Technology Collaboration
User: Password:



Roger Kitain's Blog

Roger Kitain Roger is the JavaServer Faces co-specification lead. Roger has extensively been involved with server side web technologies and products since 1997. He started working on JavaServer Faces in 2001, as a member of the reference implementation team. He has experience with Servlet, JSP technologies, and most recently he has been involved with different rendering technologies for JSF.



ICEFaces 2.0 And JSF 2.0 Together

Posted by rogerk on May 25, 2009 at 04:40 PM | Permalink | Comments (1)

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 {
            super.processPartial(phaseId);
        }
    }
...
}

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:

<partial-response>
   <changes>
      <update id="user">
         ...
      </update>
      <update id="password">
         ...
      </update>
      ...
   </changes>
</partial-response>

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.

Summary

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.

References

ICEFaces 2.0
JavaServer Faces 2.0 Specification
Project Mojarra
GlassFish





May 2009
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            


Search this blog:
  

Categories
Community: Java Enterprise
J2EE
Archives

May 2009
October 2008
September 2008
July 2007
June 2007
January 2007
July 2006
June 2006
May 2006
April 2006
August 2005
June 2005

Recent Entries

ICEFaces 2.0 And JSF 2.0 Together

"JSF and Ajax Past, Present and Future" @ AjaxWorld

JavaServer Faces 2.0 Early Draft Review 2 And JavaScript?



Powered by
Movable Type 3.01D


 Feed java.net RSS Feeds