How to transfer Primefaces AjaxStatus to JSF?

How to add a delay (for example, 300 ms) when "AjaxStatus" for Primefaces will be displayed. Right now, it is always displayed whenever an Ajax request is expected. This is unpleasant, for example, in onkeyUp events, when each key stroke leads to a download dialog within a second.

Here is my AjaxStatus download indicator component:

<p:ajaxStatus id="startAjax" onstart="PF('start').show();" oncomplete="PF('start').hide();" >
</p:ajaxStatus>

<p:dialog widgetVar="start" showHeader="false" resizable="false">
    <h:graphicImage value="#{resource['/images/loading.gif']}"></h:graphicImage>
</p:dialog>
+4
source share
1 answer

PF ( "start" ). start() , . , onComplete , , . , , ajax .

- ( )

<p:ajaxStatus id = "startAjax" onstart = "startHandler();" oncomplete = "endHandler();"/>
    <script>
        var ajaxInProgress;
        function startHandler() {
            ajaxInProgress = setTimeout(function () {
                PF('start').show();
            }, 3000);
        }
        function endHandler() {
            clearTimeout(ajaxInProgress);
            PF('start').hide();
            ajaxInProgress = null;
        }
    </script>
+6

All Articles