Polling of progressBar not started
jobame Jul 29, 2013 7:35 AMIn the following example an ajax-button can be used to trigger a process via the backing bean. The backing bean is in view scope. The process can be as well triggered automatically by a timer service.
When using the command button the progress bar is being displayed as expected. The listener is started and calculating a percentage. Once the process is done "pollEnabled" is false and only the "grid" component is rendered again.
However, when the process is triggered by the timer service and the user navigates to the page which contains the progress bar the polling of the progress bar does not start (only "initial" is being displayed even after the process ended). That is strange since the polling component "polrating" starts and e.g. the "grid" and "processControlTable" components are rendered in the given interval. Just the progress bar is not working as expected.
How can I solve that? Can the polling for the progress bar only be started via a button on the very same page (as given in the showcase)? If so, why does the polling of the component "polrating" start once the user navigates on the page?
<h:form> <a4j:poll id="polrating" interval="2000" enabled="#{bb.pollEnabled}" action="#{bb.incrementPoller}" render="polrating, grid, pb, processControlTable" /> </h:form>
<h:form> <h:panelGrid columns="1" id="grid"> <a4j:commandButton value="Start" action="#{bb.startAProcess()}" render="polrating, grid, pb" rendered="#{!bb.pollEnabled}"> <a4j:param value="#{!bb.pollEnabled}" assignTo="#{bb.pollEnabled}" /> </a4j:commandButton> </h:panelGrid> </h:form>
<h:form id="progressBarForm"> <rich:progressBar mode="ajax" value="#{bb.currentValue}" interval="2000" id="pb" enabled="#{bb.pollEnabled}" minValue="0" maxValue="100"> <f:facet name="initial"> <h:outputText value="initial" /> </f:facet> <f:facet name="finish"> <h:outputText value="finish" /> </f:facet> <h:outputText value="#{bb.currentValue} %" /> <a4j:ajax event="begin" listener="#{bb.calculatePercentage}" /> </rich:progressBar> </h:form>
<h:panelGroup id="processControlTable"> <h:outputText value="Process control table" rendered="#{bb.pollEnabled and not empty bb.processList}" styleClass="paragraph" /> <rich:dataTable value="#{bb.processList}" var="process" rendered="#{bb.pollEnabled and not empty bb.processList}"> <rich:column> <f:facet name="header">#{msgs.procTableEntryClassName}</f:facet> <h:outputText value="#{process.owner}" /> </rich:column> </rich:dataTable> </h:panelGroup>