Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how does PrimeFaces' AjaxStatus work?

I am trying to understand PrimeFaces' AjaxStatus indicator.

There are two facets - start and complete.

Can anybody tell me, what really determines start and complete.

I am just trying to make the indicator GIF image visible when user clicks a button and make it disappear when he click another button.

If whatever I am trying to achieve does not make any sense, an explanation would be really helpful.

Thanks.

like image 636
Bhesh Gurung Avatar asked May 10 '11 14:05

Bhesh Gurung


1 Answers

ajaxStatus component works with globally set components. This means that a commandButton with the attribute:

global="true"

will trigger a process that will make use of ajaxStatus component (will update it's output). This said, ajaxStatus start facet will work when the listener method is called and will update when the complete status is reached, this is, when the lifecycle of the call ends.

As I understand, this will not take care of the success or failure of the process. For this statuses, you also have other facets available: error and success.

<p:ajaxStatus> 
    <f:facet name="prestart">
    <h:outputText value="Starting..." /> </f:facet>
    <f:facet name="error"> <h:outputText value="Error" />
    </f:facet>
    <f:facet name="success"> <h:outputText value="Success" />
    </f:facet>
    <f:facet name="default"> <h:outputText value="Idle" />
    </f:facet>
    <f:facet name="start"> <h:outputText value="Please Wait" />
    </f:facet>
    <f:facet name="complete"> <h:outputText value="Done" />
    </f:facet> 
</p:ajaxStatus>

There is an ajax loading gif bundled with PrimeFaces:

<h:graphicImage library="primefaces" name="jquery/ui/ui-anim_basic_16x16.gif" />
like image 57
frandevel Avatar answered Sep 21 '22 01:09

frandevel