0

I started using the poll component of Primefaces. Goal: refresh a confirmDialog window which acts as a progress bar. The xhtml:

<h:form id="pbForm" prependId="false">
    <p:confirmDialog id ="progressBar" message= ""
                     header="Retrieving information..."
                     widgetVar="pbar"
                     severity="info">
        <h:outputText id="PBlaunch" value="#{pBLaunchSearch.getLaius()}"/>
        <p:poll interval="1" update="PBlaunch" />
    </p:confirmDialog>
</h:form>

My bean for the progress bar:

@ManagedBean
@RequestScoped

public class PBLaunchSearch {

    private static StringBuilder sb = new StringBuilder();

    public static void setLaius(String toAdd) {
        sb.append(toAdd);
        sb.append("<br>");
    }

    public static String getLaius() {
        return sb.toString();
    }

    public static void resetLaius() {
        sb = new StringBuilder();
    }
}

The operation which takes time in the background is a few API calls. After each API call that finishes, I have this command:

PBLaunchSearch.setLaius("another API call returned");

Problem: the confirmDialog remains empty (outputText id="PBlaunch" remains empty) until all the API calls have been made, at which point all the messages appear at once (but too late...)

Any clue as to why?

4

0 回答 0