0
votes

I have a datatable that has both a rowSelect ajax event (for selecting a row and showing some extra information on some bottom panels) and a rowDblselect ajax event (for opening that record in an edit window).

<p:ajax event="rowSelect" listener="#{myBean.onSagRowSelect}" update=":bottomPanel" />
<p:ajax event="rowDblselect" listener="#{myBean.onSagRowDblClick}" update=":content" onstart="startWait();" oncomplete="stopWait();"/>

This worked fine until we added an ajaxStatus component that is meant to show a loading bar gif when an ajax call is made, to let the user know that something is happening in the page. The problem is that this ajaxSTatus component is blocking my rowDblselect event, now it will only trigger rowSelect event, even if I double click a row.

    <p:ajaxStatus onstart="PF('loadingDialog').show()" onsuccess="PF('loadingDialog').hide()" />
    <p:dialog widgetVar="loadingDialog" modal="true" draggable="false" closable="false" resizable="false" showHeader="false">
        <p:graphicImage name="../images/ajaxloadingbar.gif" />
     </p:dialog> 

We're using Primefaces 5.2.

Is there any way I can configure the ajaxStatus to delay the onstart or something similar so that it allows my double click event to complete?

Any help/advice on this matter is welcomed. Thank you!

1

1 Answers

0
votes

I haven't tried that myself, but I think you could delay displaying the dialog for all events using JavaScript setTimeout, like this:

<p:ajaxStatus onstart="setTimeout(function() { PF('loadingDialog').show(); }, 500);"
    onsuccess="PF('loadingDialog').hide()" />

Other option would be to set global="false" to the p:ajax for rowSelect only - it should stop triggering ajaxStatus for this particular event. You would then have to define onstart attribute to show the dialog with delay (as shown above) and oncomplete to hide it again:

<p:ajax event="rowSelect" listener="#{myBean.onSagRowSelect}" update=":bottomPanel"
    global="false"
    onstart="setTimeout(function() { PF('loadingDialog').show(); }, 500);"
    oncomplete="PF('loadingDialog').hide();" />

By the way, I think you should really use oncomplete instead of onsuccess in this case since in case the ajax request fails for some reason, the dialog may stay displayed, blocking your application due to its modality.