My progressbar is not updated, why ? The controller method is called as it should and the progess variable is correctly incremented:
XHTML
<p:dialog>
<h:outputLabel value="Count:" for="batchCount"/>
<p:inputText id="batchCount" required="true"
value="#{batchModel.count}">
</p:inputText>
<p:commandButton id="generateBatchButton" value="GO"
actionListener="#{batchController.sendBatch()}"
onclick="PF('progressVar').start();"
oncomplete="PF('dialogBatchParams').hide();"/>
<p:progressBar id="progressBar"
widgetVar="progressVar"
value="#{batchModel.progress}"
labelTemplate="{value}%">
</p:progressBar>
</p:dialog>
CONTROLLER Method
public void sendBatch() {
for (int i = 0; i < batch.size(); i++) {
batchModel.setProgress(Math.round(100 * (float) i / (float) batch.size()));
// Do stuff here
}
}
MODEL
@Named
@ViewScoped // or @SessionScoped
public class BatchModel implements Serializable {
private static final long serialVersionUID = 1L;
private int count = 100;
private int progress;
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public int getProgress() {
return progress;
}
public void setProgress(int progress) {
this.progress = progress;
}
}
My progress is correctly updated, I get this output when logging it:
2016-10-19 10:08:49,707 INFO controller.BatchController -> Sending batch
0
10
20
30
40
50
60
70
80
90
2016-10-19 10:08:57,432 INFO controller.BatchController -> Done sending batch
I am using PF 6. I tried with and without "update" tag, and I played around with the ajax tag, but no dice.
@ViewScoped
onBatchModel
(and your controller). – Jasper de VriesBatchModel#getProgress()
is giving you the correct values? – Jasper de Vriesajax="true"
to your progress bar? – Jasper de Vries