vendredi 5 juin 2015

JSF/Primefaces: GIF animation freezes when the backend bean thread is in sleep state

I am trying pause a transaction triggered by a JSF/primeface UI by placing the following code snipped in the function within a managed bean. When the user clicks the submit button, it triggers a function which contains the below sleep statement and after waking up the function performs several other stuff:

    try {
        Thread.sleep(3000);
    } catch (InterruptedException e1) {
        LOG.error(e1.getMessage());
    }

But the above sleep statement freezes the frontend GIF animation. My intention for pausing through the mbeans was to achieve a good user perceived performance when the program is trying to avoid few backend race conditions.

How to make sure that the browser thread does not get paused when the backend thread is in sleep mode?

Here is the global ajaxstatus tag I am using from primefaces framework:

<p:ajaxStatus onstart="PF('statusDialog').show()"
                onsuccess="PF('statusDialog').hide()" />

            <p:dialog widgetVar="statusDialog" modal="false" draggable="false"
                closable="false" resizable="false" showHeader="false">
                <h:graphicImage value="resources/customimages/loading_mini.gif" />
            </p:dialog>

Aucun commentaire:

Enregistrer un commentaire