我開始研究RichFaces的4.2.2並有簡單的例子,一個問題,我有一個xml:A4J:AJAX監聽例外MethodNotFoundException
<ui:define name="content">
<h:form>
<rich:panel style="width: 50%">
<h:panelGrid columns="2">
<h:outputText value="Name:"/>
<h:inputText id="inp" value="#{echoBean.name}">
<a4j:ajax event="keyup" render="echo count" listener="#{echoBean.countListener}"/>
</h:inputText>
<h:outputText value="Echo:"/>
<h:outputText id="echo" value="#{echoBean.name}"/>
<h:outputText value="Count:"/>
<h:outputText id="count" value="#{echoBean.count}"/>
</h:panelGrid>
<a4j:commandButton value="Submit" actionListener="#{echoBean.countListener}" render="echo, count"/>
</rich:panel>
</h:form>
</ui:define>
和一個簡單的bean:
@Component("echoBean")
@Scope(value = "session")
public class EchoBean {
private String name;
private Integer count = 0;
//getter setter methods here
public void countListener(ActionEvent event) {
count++;
}
}
而當我嘗試在inputText中打印時,我有例外:
Caused by: javax.el.MethodNotFoundException: /home.xhtml @35,112 listener="#{echoBean.countListener}": Method not found: [email protected]()
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:102)
at org.ajax4jsf.component.behavior.MethodExpressionAjaxBehaviorListener.processAjaxBehavior(MethodExpressionAjaxBehaviorListener.java:71)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:98)
at org.ajax4jsf.component.behavior.AjaxBehavior.broadcast(AjaxBehavior.java:348)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:763)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
... 19 more
但是爲什麼?使用按鈕這個相同的偵聽器工作得很好,並在文檔中的「聽衆」參數在a4j:ajax它說:
該表達式必須評估爲一個公共方法,需要一個ActionEvent參數,返回類型爲void,或者公共方法不帶參數,返回類型爲void
爲什麼它使用countListener()
而沒有ActionEvent
參數?我不明白。
THX我看了一下面孔動作事件,並沒有找到有關AjaxBehaviourEvent什麼 – Wizzard
AjaxBehaviorEvent – user738048