TOC PREV NEXT INDEX

SessionRender for Ajax Push


Our final step in adding Ajax Push features to our application counter requires modifications to the ApplicationCounter. What we want is for updates to be pushed out whenever there is a change. To do this, you simply need to call the render method of the SessionRenderer when a notable change occurs.

public static void render(final String groupName)
 

 

Copy or type the bolded section of code into the ApplicationCounter.java file:

package org.icefaces.tutorial;
 

 
import javax.faces.event.ActionEvent;
 
import com.icesoft.faces.async.render.SessionRenderer;
 

 
public class ApplicationCounter extends Counter {
 

 
    public ApplicationCounter() {
 
    }
 

 
    public synchronized void setCount(int count){
 
        super.setCount(count);
 
        SessionRenderer.render("all");
 
    }
 

 
    public synchronized void increment(ActionEvent event) {
 
        super.increment(event);
 
        SessionRenderer.render("all");
 
   }
 

 
    public synchronized void decrement(ActionEvent event) {
 
        super.decrement(event);
 
        SessionRenderer.render("all");
 
   }
 

 
}
 

So whenever we note a change to the application-scoped counter, we issue a request for a render to the group "all" which, in our case, means every active session.



Copyright 2005-2009. ICEsoft Technologies, Inc.
TOC PREV NEXT INDEX