a4j:push
patrickmadden Sep 25, 2007 4:10 PMI'm trying to get a4j:push working on one of my pages. I have an entity bean with application scope that listens to events regarding resources going up and down on an enterprise network. My page shows tables inside tabs of said resources. Resources can be things like services etc that are installed on arbitrary machines on my network. When a service goes up or down my enterprise bean recieves an event. When this occurs, I add an event to my PushEventListeners for a particular resource. The backend is all working and I can see that the events are being added correctly to each of my PushEventListeners.
Here is a snip of the backend bean:
/** * This method is used to push asynchronous events to the client * when we get add/remove or update events for grid members * we are interested in. */ public void processEvent(GridMemberEvent event) { IGridMember member = event.getGridMember(); if (member == null) { log.warn("Received a null IGridMember"); return; } switch (event.getEventType()) { case Added: case Removed: case Update: { log.info("Grid Member " + event.getEventType().toString() + " from address " + event.getSrcAddress() + ", " + member.toString()); if (member instanceof IIndexingGridMember) { if (this.indexingMemberPushListener != null) { synchronized (this.indexingMemberPushListener) { log.info("Pushing event onto indexingMemberPushListener"); this.indexingMemberPushListener.onEvent(new EventObject(this)); } } else { log.warn("Recieved an IIndexingGridMember but our listener is null"); } } else if (member instanceof ICloosterAppServer) { if (this.appServerMemberPushListener != null) { synchronized (this.appServerMemberPushListener) { log.info("Pushing event onto appServerMemberPushListener"); this.appServerMemberPushListener.onEvent(new EventObject(this)); } } else { log.warn("Recieved an ICloosterAppServer but our listener is null"); } } } break; .... }
I see the correct log messages on the backend but the page is not rerendering correctly.
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j" template="layout/template.xhtml"> <ui:define name="body"> <h:messages globalOnly="true" styleClass="message"/> <a4j:region> <h:form> <a4j:push reRender="indexingGridMembersTable" eventProducer="#{enterpriseGrid.addIndexingGridMemberPushEventListener}" interval="10000"/> <a4j:push reRender="appServerGridMembersTable" eventProducer="#{enterpriseGrid.addAppServerGridMemberPushEventListener}" interval="10000"/> </h:form> </a4j:region> <h:form id="enterpriseGridViewForm"> <f:facet name="header">Enterprise Grid Components</f:facet> <rich:tabPanel id="enterpriseGridViewTab" switchType="ajax"> <rich:tab id="appServerGridMembersTab" label="Search Portals"> <rich:dataTable id="appServerGridMembersTable" rows="10" value="#{enterpriseGrid.cloosterAppServers}" var="appServer"> ... </rich:dataTable> </rich:tab> <rich:tab id="indexingGridMembersTab" label="Indexing Servers"> <rich:dataTable id="indexingGridMembersTable" rows="10" value="#{enterpriseGrid.indexingGridMembers}" var="indexingServer"> ... </rich:dataTable> </rich:tab> </rich:tabPanel> </h:form> </ui:define> </ui:composition>
I've tried this with and without the a4j:region code.
Any idea as to what I'm doing wrong?
Thanks in advance and great job and 3.1.x.
PVM