On my webpage I use global ajax status that is modal one. That is, when there is an ajax call, the user is blocked from performing other actions and is forced to wait. Like here:
http://www.primefaces.org/showcase-labs/ui/ajaxStatusScript.jsf
However, such behavior is not desired for all components on the page. For example, for autocomplete it would be nicer to have non-blocking one just next to autocomplete component. In RichFaces, there was status attribute by autocomplete component.
In PrimeFaces (3.4 SNAPSHOT), is there a way how to have two different ajax statuses on the page trigger them independently as needed?
Thanks, Lukas
You can use the global attribute whether to trigger ajaxStatus or not. For example, setting it false will not trigger ajaxStatus like this:
<p:autoComplete id="acSimple" value="#{autoCompleteBean.txt1}"
completeMethod="#{autoCompleteBean.complete}" global="false"/>
For other components where you are updating with ajax. You can do some thing like this:
<p:inputText value="#{autoCompleteBean.txt1}">
<f:validateLength minimum="2" />
<p:ajax global="false" update="email" event="keyup"/>
</p:inputText>
UPDATE : If you want two status then do write your own dialog like this:
<p:dialog widgetVar="status" modal="true" closable="false">
Please Wait
</p:dialog>
<p:inputText value="#{autoCompleteBean.txt1}">
<f:validateLength minimum="2" />
<p:ajax global="false" onstart="status.show()" oncomplete="status.hide()" update="email" event="keyup"/>
</p:inputText>
In Primefaces 5.1 you will see a warning with Ravi's solution and it will not work.
27-Mar-2015 14:35:41.877 WARNING [http-apr-8080-exec-2] org.primefaces.component.autocomplete.AutoCompleteRenderer.encodeScript The process/global/onstart/oncomplete attribute of AutoComplete was removed. Please use p:ajax with the query event now
The correct solution for Primefaces 5.1 is to add
<p:ajax event="query" global="false"/>
inside the autoComplete tag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With