Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Question was asked more than a year ago, but here are some code snippets that hopefully will help someone else in the future:</p> <pre><code> &lt;h:panelGrid&gt; &lt;p:progressBar widgetVar="progressBar" ajax="true" value="#{archiveCopyCreator.progress}" interval="1000" labelTemplate="{value}%" styleClass="animated" style="width: 500px;"&gt; &lt;p:ajax event="complete" listener="#{archiveCopyCreator.onComplete}"/&gt; &lt;/p:progressBar&gt; &lt;h:panelGrid styleClass="centered"&gt; &lt;p:commandButton value="Avbryt" action="cancel" ajax="false" immediate="true" /&gt; &lt;/h:panelGrid&gt; &lt;/h:panelGrid&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { progressBar.start(); }); &lt;/script&gt; </code></pre> <p>I create a progressBar, and update it based on a value in one of my beans. When complete, a ajax call is made to the bean. The progressbar is started manually using javascript.</p> <pre><code>@Component public class ArchiveCopyCreator implements Serializable { private static final long serialVersionUID = 1L; protected Integer progress; public Integer getProgress() { if (this.progress == null) { this.progress = 0; } else { this.progress = this.progress + (int) (Math.random() * 15); if (this.progress &gt; 100) { this.progress = 100; } } return this.progress; } public void setProgress(final Integer progress) { this.progress = progress; } public void cancel() { this.progress = null; } public void reset() { this.progress = null; } public boolean hasProgress() { return this.progress != null; } public void onComplete() { RequestControlContext requestContext = (RequestControlContext) RequestContextHolder.getRequestContext(); this.objektidentiteter = null; this.progress = null; requestContext.handleEvent(new Event(this, "complete")); return; } </code></pre> <p>}</p> <p>Actual progress is faked using Math.random in this example.</p> <p>Note that onComplete() is called using ajax from progressBar. That javacode does a transition to my next Spring Webflow state with the id "complete".</p> <p>Remember to create a new backing bean for each user/flow... ArchiveCopyCreator in my example is a @Component since i want to share it between flows and users.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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