【问题标题】:Managed bean not called on a4j:jsFunction未在 a4j:jsFunction 上调用托管 bean
【发布时间】: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


【解决方案1】:

请检查a4j:jsFunctionform 中。

组件使用标准 JSF 机制发送请求。笔记 这意味着需要一个 JSF 表单。

另见http://showcase.richfaces.org/richfaces/component-sample.jsf?demo=jsFunction&skin=classic

【讨论】:

    猜你喜欢
    • 2013-07-15
    • 2012-12-18
    • 2012-05-18
    • 2013-09-10
    • 2012-10-03
    • 2013-10-02
    • 2013-10-19
    • 2011-12-23
    相关资源
    最近更新 更多