package example; import com.icesoft.faces.async.render.IntervalRenderer; import com.icesoft.faces.async.render.RenderManager; import com.icesoft.faces.async.render.Renderable; import com.icesoft.faces.component.menubar.MenuItem; import com.icesoft.faces.context.DisposableBean; import com.icesoft.faces.webapp.xmlhttp.PersistentFacesState; import com.icesoft.faces.webapp.xmlhttp.RenderingException; import java.util.ArrayList; import java.util.List; public class TestBean implements Renderable, DisposableBean { private final List menu; private final PersistentFacesState state; private IntervalRenderer renderer; public TestBean() { System.out.println("TestBean instantiated"); // get hold of the ICEfaces state object this.state = PersistentFacesState.getInstance(); // build the menu this.menu = new ArrayList(); MenuItem item; MenuItem subItem; item = new MenuItem(); item.setValue("One"); subItem = new MenuItem(); subItem.setValue("One.1"); item.getChildren().add(subItem); subItem = new MenuItem(); subItem.setValue("One.2"); item.getChildren().add(subItem); this.menu.add(item); item = new MenuItem(); item.setValue("Two"); subItem = new MenuItem(); subItem.setValue("Two.1"); item.getChildren().add(subItem); subItem = new MenuItem(); subItem.setValue("Two.2"); item.getChildren().add(subItem); this.menu.add(item); } public List getMenu() { return this.menu; } public void setRenderManager(final RenderManager renderManager) { // use the supplied RenderManager to obtain an interval renderer // (the RenderManager will create one if required) this.renderer = renderManager.getIntervalRenderer("clockRG"); // set the clock ticking (once per second) this.renderer.setInterval(1000); // add this object to the renderers list of objects to render this.renderer.add(this); // start the interval renderer ticking renderer.requestRender(); System.out.println("Renderer started"); } public PersistentFacesState getState() { return this.state; } public void renderingException(RenderingException renderingException) { // remove this renderable if (this.renderer != null) { this.renderer.remove(this); this.renderer = null; } } public void dispose() { // remove this renderable if (this.renderer != null) { this.renderer.remove(this); this.renderer = null; } } }