I am using JSF 2.x and richfaces. I have following requirement to be implemented.
This image describes that step1 is completed sucessfully, step2 is under progress and step3 is yet to be started.
I have following backing bean code
public void doAllSteps() {
// set step1 flag started
// do step1
// set step1 flag success
// set step2 flag under_progress
// do step2
// set step2 flag success
// set step3 flag under_progress
// do step3
// set step 3 flag success
}
// There will be getters for all the flags
Now then in .xhtml
page I did following
<a4j:poll id="poll" interval="1000" enabled="true" render="gr-img-status-panel" />
<a4j:outputPanel id="gr-img-status-panel">
<div class="row mr-top1">
<div class="col-xs-12">
<h4 class="text-white text-left">
Step 1
<h:panelGroup rendered="#{myBean.step1Status eq 0}">
(Processing ...)
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step1Status eq 1}">
<span style="color: green;">✔</span>
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step1Status eq 2}">
<span style="color: red;">✗</span>
</h:panelGroup>
</h4>
<h4 class="text-white text-left">
Step 2
<h:panelGroup rendered="#{myBean.step2Status eq 0}">
(Processing ...)
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step2Status eq 1}">
<span style="color: green;">✔</span>
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step2Status eq 2}">
<span style="color: red;">✗</span>
</h:panelGroup>
</h4>
<h4 class="text-white text-left">
Step 3
<h:panelGroup rendered="#{myBean.step3Status eq 0}">
(Processing ...)
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step3Status eq 1}">
<span style="color: green;">✔</span>
</h:panelGroup>
<h:panelGroup rendered="#{myBean.step3Status eq 2}">
<span style="color: red;">✗</span>
</h:panelGroup>
</h4>
</div>
</div>
</a4j:outputPanel>
Also I have a a4j:commandButton
where I execute the doAllSteps()
.
Problem
When 1st time I load the page a4j polling starts (it is fine for me). But as soon as I click the a4j:commandButton
, the polling stops. After a4j:commandButton
executed completely a4j polling start again. So it means that I cannot execute 2 a4j requests simultaneously.
How can I achieve my goal ?