How to delay Primefaces AjaxStatus on JSF?
You need to wrap your PF('start').start() with a function which will call it with a delay. Also, the onComplete handler should check if you have pending status to show and cancel them. This is to avoid the case where ajax finished before status displayed.
Code should be something like this (not tested)
<p:ajaxStatus id = "startAjax" onstart = "startHandler();" oncomplete = "endHandler();"/>
<script>
var ajaxInProgress;
function startHandler() {
ajaxInProgress = setTimeout(function () {
if(ajaxInProgress){
PF('start').show();
}
}, 3000);
}
function endHandler() {
clearTimeout(ajaxInProgress);
PF('start').hide();
ajaxInProgress = null;
}
</script>
I submitted a PR that this delay attribute will be native in PF 7.1+.
https://github.com/primefaces/primefaces/pull/5138
Thanks for the suggestion!