package com.icefaces.support.example; import com.icesoft.faces.async.render.OnDemandRenderer; import com.icesoft.faces.async.render.RenderManager; import com.icesoft.faces.async.render.Renderable; import com.icesoft.faces.component.ext.HtmlDataTable; 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 javax.faces.event.ActionEvent; public class TestBean implements Renderable, DisposableBean { private PersistentFacesState state; private RenderManager renderManager; private OnDemandRenderer userGroup; private ArrayList resourceList; private String newFile; private String newMime; private HtmlDataTable resourceTable; public TestBean() { resourceList = new ArrayList(); resourceList.add(new TableItem("WP_Security_Whitepaper.pdf", "application/pdf")); resourceList.add(new TableItem("logo.jpg", "image/jpeg")); state = PersistentFacesState.getInstance(); } public void addNewResource(ActionEvent event) { TableItem ti = new TableItem(newFile, newMime); resourceList.add(0, ti); userGroup.requestRender(); } public HtmlDataTable getResourceTable() { return resourceTable; } public void setResourceTable(HtmlDataTable resourceTable) { this.resourceTable = resourceTable; } public ArrayList getResourceList() { return resourceList; } public void setResourceList(ArrayList resourceList) { this.resourceList = resourceList; } public String getNewFile() { return newFile; } public void setNewFile(String newFile) { this.newFile = newFile; } public String getNewMime() { return newMime; } public void setNewMime(String newMime) { this.newMime = newMime; } public void setRenderManager(RenderManager renderManager) { this.renderManager = renderManager; userGroup = renderManager.getOnDemandRenderer("userGroup"); userGroup.add(this); } public PersistentFacesState getState() { return state; } public void renderingException(RenderingException exception) { exception.printStackTrace(); userGroup.remove(this); } public void dispose() throws Exception { userGroup.remove(this); } }