Using JDev 10.1.3.5.0. Yes, it's archaic.
I've spent the past two days trying to get a <af:poll> component to work with no success. I've gone through tutorials and gotten them to work, but my personal use case will not.
A dialog window opens. When this dialog loads, a poll component begins refreshing a progress indicator every 2 seconds. This works; I can see the refresh happening. Inside this dialog, a user then clicks a "Start" button, triggering an actionEvent method.
public void startAction(ActionEvent actionEvent) {
// initialize progress indicator's range model to 0
this.simpleBoundedRangeModel.start(actionEvent);
// Begin performing a business process.
ManagementDashboardExport pbm = (ManagementDashboardExport)EL.get("#{ManagementDashboardExport}");
pbm.exportDashboard();
}
In that bean, a process runs which then updates the progress indicator's model
public String exportDashboard(){
private PollingBackingBean pbm = (PollingBackingBean)EL.get("#{PollingBB}");
// do a bunch of work and at a certain milestone, set that 20% of the work has been done.
pbm.getSimpleBoundedRangeModel().setValue(20);
// continue doing work
...
}
The problem is that at the point exportDashboard() begins, the polling quits! The program keeps running and eventually finishes, but the progress indicator never refreshes.
How can a file download/upload process work, but my process not? This seems like some kind of threading issue. I'm trying to show the progress of a running process. Any ideas on how I can get this to work?
Thanks,
Will
PS: The .jspx code and PollingBackingBean class
<af:form id="f1">
<af:panelGroup id="pgl1">
<af:panelGroup id="pgl2" layout="horizontal">
<af:commandButton text="Start" id="cb1" partialSubmit="true" actionListener="#{PollingBB.startAction}"/>
<af:objectSpacer width="10" height="10" id="s1"/>
<af:commandButton text="Cancel" id="cb2" partialSubmit="true" actionListener="#{PollingBB.cancelAction}"/>
</af:panelGroup>
<af:objectSpacer width="10" height="10" id="s2"/>
<af:poll interval="2000" id="poll" pollListener="#{PollingBB.pollMe}" binding="#{PollingBB.pollComponent}" rendered="true"/>
<af:progressIndicator id="pi1" rendered="true" partialTriggers="poll" value="#{PollingBB.simpleBoundedRangeModel}"/>
</af:panelGroup>
</af:form>
public class PollingBackingBean {
SimpleBoundedRangeModel simpleBoundedRangeModel;
private int pollInterval = -1;
private CorePoll pollComponent;
public void startAction(ActionEvent actionEvent) {
this.simpleBoundedRangeModel.start(actionEvent);
ManagementDashboardExport pbm = (ManagementDashboardExport)EL.get("#{ManagementDashboardExport}");
pbm.exportDashboard();
}
public void cancelAction(ActionEvent actionEvent) {
this.pollInterval = -1;
this.pollComponent.setRendered(false);
this.simpleBoundedRangeModel.cancelProcess(actionEvent);
AdfFacesContext.getCurrentInstance().addPartialTarget(this.pollComponent);
}
public void pollMe(PollEvent pollEvent) {
if (this.simpleBoundedRangeModel != null) {
if (this.simpleBoundedRangeModel.getValue() < this.simpleBoundedRangeModel.getMaximum()) {
System.out.println("Polling Event Triggered");
} else {
this.pollInterval = -1;
AdfFacesContext.getCurrentInstance().addPartialTarget(this.pollComponent);
this.simpleBoundedRangeModel.setValue(0L);
}
}
}
public SimpleBoundedRangeModel getSimpleBoundedRangeModel() {
if (this.simpleBoundedRangeModel == null)
this.simpleBoundedRangeModel = new SimpleBoundedRangeModel();
return this.simpleBoundedRangeModel;
}
public void setPollInterval(int pollInterval) {
this.pollInterval = pollInterval;
}
public int getPollInterval() {
return pollInterval;
}
public void setPollComponent(CorePoll pollComponent) {
this.pollComponent = pollComponent;
}
public CorePoll getPollComponent() {
return pollComponent;
}
}