ajax PrimeFaces 的 AjaxStatus 是如何工作的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5951746/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how does PrimeFaces' AjaxStatus work?
提问by Bhesh Gurung
I am trying to understand PrimeFaces' AjaxStatus indicator.
我试图了解 PrimeFaces 的 AjaxStatus 指标。
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.
我只是想在用户单击按钮时使指示器 GIF 图像可见,并在他单击另一个按钮时使其消失。
If whatever I am trying to achieve does not make any sense, an explanation would be really helpful.
如果我试图实现的目标没有任何意义,那么解释将非常有帮助。
Thanks.
谢谢。
回答by frandevel
ajaxStatus component works with globally set components. This means that a commandButton with the attribute:
ajaxStatus 组件与全局设置的组件一起工作。这意味着具有以下属性的 commandButton:
global="true"
will trigger a process that will make use of ajaxStatus component (will update it's output).
This said, ajaxStatus startfacet will work when the listener method is called and will update when the completestatus is reached, this is, when the lifecycle of the call ends.
将触发一个使用 ajaxStatus 组件的进程(将更新它的输出)。这就是说,ajaxStatus startfacet 将在调用侦听器方法时起作用,并在complete达到状态时更新,即调用的生命周期结束时。
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: errorand success.
据我了解,这不会影响过程的成败。对于此状态,您还可以使用其他方面:error和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:
PrimeFaces 捆绑了一个 ajax 加载 gif:
<h:graphicImage library="primefaces" name="jquery/ui/ui-anim_basic_16x16.gif" />

