问题描述
这是代码:
<p:ajax event="eventResized" process="@this calendar" listener="#{bean.eventResized}" oncomplete="resizeComplete()"/>
由AjaxBehaviorEvent
扩展的EventResizeBehavior
调用的
eventReized
,它包含一些属性.我可以在<p:ajax....>
内部检查其值并将结果传递给oncomplete="resizeComplete(result)"
eventReized
invoked by EventResizeBehavior
which extended from AjaxBehaviorEvent
and it contains some property. Can I check inside <p:ajax....>
call its value and pass result to oncomplete="resizeComplete(result)"
类似的东西
<p:ajax event="eventResized" process="@this calendar" listener="#{bean.eventResized}" oncomplete="resizeComplete(#{eventResized.id == 0})"/>
推荐答案
PrimeFaces不支持它.在oncomplete
属性中的所有EL表达式都将在该HTML文档的呈现响应期间立即评估,而不是在关联的ajax调用完成时评估.基本上,oncomplete
属性生成的JavaScript代码包含页面加载期间的旧值.
PrimeFaces doesn't support it. Any EL expressions in oncomplete
attribute are immediately evaluated during render response of that HTML document, not during oncomplete of the associated ajax call. Basically, the JavaScript code generated by oncomplete
attribute contains the old value as it was during the page load.
您最好的选择是使用 RequestContext#addCallbackParam()
,以将属性添加到特定于PrimeFaces的args
对象,该对象在oncomplete
范围内可用.
Your best bet is using RequestContext#addCallbackParam()
to add a property to the PrimeFaces-specific args
object which is available in oncomplete
scope.
RequestContext.getCurrentInstance().addCallbackParam("result", eventResized.getId() == 0);
<p:ajax ... oncomplete="resizeComplete(args.result)" />
一种替代方法是使用 RequestContext#execute()
而不是oncomplete
来以编程方式指示PrimeFaces在ajax请求完成时执行一段JavaScript.
An alternative is to use RequestContext#execute()
instead of oncomplete
to programmatically instruct PrimeFaces to execute a piece of JavaScript on complete of the ajax request.
RequestContext.getCurrentInstance().execute("resizeComplete(" + (eventResized.getId() == 0) + ")");
这篇关于如何在操作方法期间更新的PrimeFaces oncomplete属性中使用EL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!