如何以编程AJAX更新在后台bean特定组件 [英] How to programmatically ajax-update specific component in backing bean
问题描述
有没有办法来AJAX的更新特定组件,如< H:形式GT;
在后台bean
Is there a way to ajax-update a specific component such as a <h:form>
in backing bean?
我尝试以下使用<一个href="http://www.primefaces.org/docs/api/3.4/org/primefaces/context/RequestContext.html#execute%28java.lang.String%29"><$c$c>RequestContext#execute()$c$c>,
I tried the following using RequestContext#execute()
,
RequestContext context = RequestContext.getCurrentInstance();
context.execute("monitorVehicleForm.update()");
但似乎没有任何效果。
however that didn't seem to have any effect.
推荐答案
在的RequestContext#的execute()
只是执行其被传入的任意JavaScript code作为参数。它不AJAX的更新组件的客户端重新presentation
The RequestContext#execute()
only executes arbitrary JavaScript code which is been passed-in as argument. It does not ajax-update the client representation of the components.
您需要的<一个href="http://www.primefaces.org/docs/api/3.4/org/primefaces/context/RequestContext.html#update%28java.lang.String%29"><$c$c>RequestContext#update()$c$c>而不是其中你只需把该待更新组件的客户端ID。
You need RequestContext#update()
instead wherein you just pass the client ID of the to-be-updated component.
context.update("monitorVehicleForm");
这具有完全相同的效果&LT;电话号码:commandXxx ...更新=monitorVehicleForm&GT;
。这个工程提供出你那
This has exactly the same effect as <p:commandXxx ... update="monitorVehicleForm">
. This works provided you've a
<h:form id="monitorVehicleForm">
没有任何<一href="http://docs.oracle.com/javaee/6/api/javax/faces/component/NamingContainer.html"><$c$c>NamingContainer$c$c>亲和因此具有
without any NamingContainer
parent and thus have a
<form id="monitorVehicleForm" name="monitorVehicleForm" ...>
在生成的HTML。
- <一个href="http://stackoverflow.com/questions/8634156/how-to-reference-components-in-jsf-ajax-cannot-find-component-with-identifier/8644762#8644762">How引用组件的JSF AJAX?无法找到标识符QUOT组成部分;富&QUOT;鉴于
这篇关于如何以编程AJAX更新在后台bean特定组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!