Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There are two problems: your Java code does not do what you want it to do and you're not telling the page to update (that won't happen automatically).</p> <p>Take a look at the <code>getCurrentValue()</code> again: It increments <code>currentValue</code> from 0 to 100 and returns the result which is 100. <code>#{progressBarBean.currentValue}</code> does not care (or know) what happens with the variable, it only cares about the result of the <code>getCurrentValue()</code> method.</p> <p>So in order for it all to work it will have to look like this:</p> <h2>Page</h2> <pre><code>&lt;a4j:commandLink action="#{progressBarBean.startProcess}" value="click here" render="pb" execute="@this"/&gt; &lt;rich:progressBar mode="ajax" value="#{progressBarBean.currentValue}" interval="1000" id="pb" enabled="#{progressBarBean.enabled}" minValue="0" maxValue="100"&gt; &lt;a4j:ajax event="begin" listener="#{progressBarBean.increment}" render="text"/&gt; &lt;h:outputText value="Retrieving #{progressBarBean.currentValue} of #{progressBarBean.totalRecords}" id="text" /&gt; &lt;/rich:progressBar&gt; </code></pre> <p>The <code>a4j:ajax</code> is fired each second (i.e. each interval), it increments the <code>currentValue</code> and updates the text.</p> <p>You also need <code>a4j:commandLink</code> (or <code>a4j:ajax</code> inside the <code>h:commandLink</code>) in order to rerender the progressbar - in your example you enable the progressbar in the bean but the value on the page does not change.</p> <h2>Bean</h2> <pre><code>public Integer getCurrentValue() { return currentValue; } public void increment() { if (isEnabled() &amp;&amp; currentValue &lt; totalRecords) { currentValue++; } } </code></pre> <p>Ask if anything isn't clear.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload