Thursday, 7 June 2007

Ajax in Spring Web Flow with ICEfaces


I've been working with Keith Donald at Interface21 to integrate Spring Web Flow with ICEfaces. The approach taken (in the current implementation) is actually very similar to the technique provided by Dan Leahu, however, by making the ICEFaces form renderer automatically include the Spring Web Flow _flowExecutionKey, no page changes are necessarily required to add ICEfaces.

To try it out, you will need ICEfaces from subversion (or, shortly, ICEfaces 1.6) and Spring Web Flow 1.0.3. Then, you can proceed to transparently add Ajax features to spring-webflow-1.0.3/projects/spring-webflow-samples/sellitem-jsf.

Add the ICEfaces .jar files to lib/global:

    icefaces-comps.jar
    icefaces.jar
    backport-util-concurrent.jar
    commons-fileupload.jar
    el-api.jar
Configure the web.xml for ICEfaces:
        
                com.icesoft.faces.standardRequestScope
                true
        
including the ICEfaces listener:
    
        com.icesoft.faces.util.event.servlet.ContextEventRepeater
    
And the servlets:
    
        Persistent Faces Servlet
        com.icesoft.faces.webapp.xmlhttp.PersistentFacesServlet
         1 
    

    
        Blocking Servlet
        com.icesoft.faces.webapp.xmlhttp.BlockingServlet
         1 
    

    
        Persistent Faces Servlet
        *.iface
    

    
        Persistent Faces Servlet
        /xmlhttp/*
    

    
        Blocking Servlet
        /block/*
    

    

    
        Persistent Faces Servlet
        *.jsp
    

(It's certainly not optimal to map *.jsp to the Persistent Faces Servlet; perhaps a ViewIDMapper is the answer.)

Then, due to a difference in behavior in MyFaces/Sun RI selectOneMenu (should an itemValue of "" be passed as "" or null to the bean?) it is necessary to test for null in Sale.setCategory():

        public void setCategory(String category) {
               this.category = (null != category) ? category : "";
        }

A tag needs to be inserted (ICEfaces is strict about XML syntax) in each of costOverview.jsp and shippingDetailsForm.jsp, and finally .faces links in intro.jsp and costOverview.jsp need to be replaced with .iface links.

Please tell us about your experiences with Spring Web Flow and ICEfaces, either here or on the forums (sample source code is available on the ICEfaces forum). You will find that the new scopes (flash, flow, and conversation) and navigation capabilities of Spring Web Flow are a very natural complement to the Ajax capabilities of ICEfaces.

Posted by ted.goddard at 12:07 PM in Entries by Ted Goddard

« June »
SMTWTFS
     12
3456789
10111213141516
17181920212223
24252627282930