3

I have multiple command buttons in my JSF ... Its a database search which has one 'Search' button and the other 'Add' button.

When clicking on 'Search' Button i wanted a status to be displayed, so i added the below ajaxStatus code to my outputPanel which is in form1 where my search results are displayed.

<p:ajaxStatus  onstart="statusDialog1.show();" onsuccess="statusDialog1.hide();"/>

Dialog Box

<p:dialog modal="true" widgetVar="statusDialog1" header="Searching ... Please wait"   
                    draggable="false" closable="false" resizable="False">  
<p:graphicImage value="/resources/ajax-loader.gif" />  
</p:dialog>

When the 'Add' button is clicked, another dialog box opens which has form2, now the problem is when i click on 'Add' Button statusDialog1 is shown as well, i want that status to be shown only when 'Search' button is clicked.

How do i use multiple agaxStatus messages in the same page ?

Telson Alva
  • 842
  • 6
  • 22
  • 37

1 Answers1

2

From the dev guide

AjaxStatus is a global notifier for ajax requests.

In other words, you will have one per page which handles all ajax processing on that page. If you are using PrimeFaces p:commandButton you can use the onstart and onsuccess attribute of your Add and Search button. Example:

<p:commandButton value="Add" onstart="statusDialog1.show();" onsuccess="statusDialog1.hide()"/>
<p:commandButton value="Search" onstart="statusDialog2.show();" onsuccess="statusDialog2.hide()"/>

Another thing you can use to "show" the ajax status of each component is PrimeFaces <p:blockUI>. You can refer to the showcase for some examples

Spartan
  • 1,167
  • 4
  • 20
  • 40
Andy
  • 5,900
  • 2
  • 20
  • 29