How to make a4j poll work in a popupPanel
sarocks Dec 8, 2015 5:15 AMHi All,
I have problems on updating a count dynamically in a popupPanel. I was making use of a4j:poll. But it doesn't seems to work.
I am sharing the code snippets, let me know if something is wrong in the code.
xhtml code:
<a4j:status name="waitCount"
onstart="#{rich:component('waitPanel')}.show();"
onstop="#{rich:component('waitPanel')}.hide();" />
<rich:popupPanel id="waitPanel" autosized="true" styleClass="body"
modal="true" domElementAttachment="parent"
style="text-align: center; background: white; border: none;"
width="240" moveable="false" resizeable="false">
<h:form id="waitform">
<a4j:poll id="rowcountpoll" interval="1000"
enabled="#{mgrBean.enablePoll}" limitRender="true"
render="waitform,rowcountpoll,rowscount,waitPanel">
</a4j:poll>
<h:outputLabel id="rowlabelmsg" style="font-size: 14px;"
value="Count : " for="rowcountpoll" />
<h:outputText id="rowscount" style="font-size: 14px;"
value="#{mgrBean.count}" />
<p />
</h:form>
</rich:popupPanel>
<h:panelGrid columns="2" width="80%" id="grid">
<h:form>
<h:outputText value="Run : " style="font-weight: bold;" />
<a4j:commandButton style="width:120px" id="control"
value="#{mgrBean.enablePoll?'Stop':'Start'} Polling"
status="waitCount" action="#{mgrBean.runPoll}"
render="grid,rowcountpoll,waitPanel,waitform">
<a4j:param name="polling" value="#{!mgrBean.enablePoll}"
assignTo="#{mgrBean.enablePoll}" />
</a4j:commandButton>
</h:form>
</h:panelGrid>
Java code:
private boolean enablePoll = false; private int count = 0;
public String runPoll() {
if (enablePoll) { do { count += 10; try { System.out.println("count : " + count); Thread.sleep(3000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } while (count <= 100); enablePoll = false; } return null; }
public boolean isEnablePoll() {
return enablePoll; }
public void setEnablePoll(boolean enablePoll) {
this.enablePoll = enablePoll; }
public String getCount() {
return Integer.toString(count); }
public void setCount(String count) {
this.count = Integer.parseInt(count); }
I am using following libraries:
myfaces - 2.2.8
richfaces - 4.5.1.Final
Thanks,
Saroj