【发布时间】:2015-12-11 19:30:34
【问题描述】:
我的 a4j:jsFunction 有问题(在 sn-p 下方):
<a4j:jsFunction
name="updateVal"
render="panelViewStation"
execute="@all"
onbegin="alert('begin');"
onbeforedomupdate="alert('onbeforedomupdate')"
oncomplete="alert('complete');"
action="#{controller.aMethod}"
actionListener="#{controller.anotherMethod}"
onerror="alert('error');">
<a4j:param name="val" assignTo="#{controller.val}"/>
</a4j:jsFunction>
在我的托管 bean 中,我有这些方法:
/** action method */
public Object aMethod() {
return "something";
}
/** action listener method */
public void anotherMethod(ActionEvent actionEvent) {
// do something
}
// get/setter for val
这个方法被下面的另一个js函数调用:
function processSelectEvent(target) {
alert(target.previousElementSibling.textContent);
updateVal(target.previousElementSibling.textContent);
}
最后这个方法被一个自动完成元素调用
<rich:autocomplete id="stationId" minChars="3" var="station" inputClass="autoCompleteWidth300" onselectitem="processSelectEvent(event.target);"
fetchValue="#{station.name}"
autocompleteMethod="#{controller.searchStations}"
mode="cachedAjax" required="true" autofill="false" layout="table">
很遗憾,该功能不如预期。 当我在自动完成列表中选择一个元素时,会调用函数 processSelectEvent。 调用了 js 函数“updateVal”,但只调用了“onbegin”javascript。 其他属性没有被调用(onbeforedomupdate、oncomplete、onerror),托管 bean 也没有被调用(action、actionListener)。
有什么办法可以解决我的问题吗?谢谢
【问题讨论】:
-
控制台有错误吗?您使用的是哪个 RichFaces 版本?
-
@Makhiel。我使用RF4。服务器控制台中没有错误。 a4j:logs 中没有错误。我唯一看到的是服务器发送部分更新(
)但在页面的另一部分 -
@Makhiel 我放了一个阶段跟踪器,所有阶段都实现了(验证阶段没有错误)
标签: javascript java jsf-2 richfaces