2013-05-01 62 views
-2
<f:actionListener binding="#{clController.getTotal((clController.year))}" /> 

我嘗試調用clController.getTotal((clController.year))函數,但我認爲存在問題。爲什麼我不能調用該函數?

爲什麼?我怎樣才能調用函數的ActionListener

我把這個ActionListener的

<h:commandButton type="submit" action="#{clController.getPaymentByMonth(clController.year)}" id="stateInfo" value="Show Monthly " > 

          </h:commandButton> 

May 1, 2013 4:27:42 PM com.sun.faces.application.view.FaceletViewHandlingStrategy handleRenderException 
SEVERE: Error Rendering View[/customerPaymentPlan.xhtml] 
javax.faces.FacesException: javax.el.ELException: /customerPaymentPlan.xhtml @84,220 onclick="#{clController.getTotal((clController.year))}": Unable to find method [getTotal] with [1] parameters 
    at javax.faces.component.UIComponentBase$AttributesMap.get(UIComponentBase.java:2350) 
    at com.sun.faces.renderkit.RenderKitUtils.renderOnclick(RenderKitUtils.java:442) 
    at com.sun.faces.renderkit.html_basic.ButtonRenderer.encodeBegin(ButtonRenderer.java:166) 
    at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:820) 
    at com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:302) 
    at com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:105) 
    at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:845) 
    at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1779) 
+2

是什麼讓你覺得有什麼問題嗎?換句話說,究竟發生了什麼?不相關的,但爲什麼額外的parens? – 2013-05-01 13:32:05

+0

你看到什麼問題? – seanhodges 2013-05-01 13:33:57

+0

我張貼錯誤以上 – user2326472 2013-05-01 13:40:24

回答

0

之間的binding屬性的值必須實現ActionListener接口不是一個方法調用的對象。

所以你會:

<f:actionListener binding="#{clController.totalListener}" />

totalListener必須實現提到的接口。

另一種可能性要調用的方法是這樣的:

<h:commandButton type="submit" action="#{clController.getPaymentByMonth(clController.year)}" actionListener="#{clController.getTotal(clController.year)}" id="stateInfo" value="Show Monthly " /> 

- 所以不使用F:ActionListener的標籤

+0

那麼我怎樣才能調用方法? – user2326472 2013-05-01 13:44:20

+0

我需要clController.getTotal()方法 – user2326472 2013-05-01 13:44:44

+0

所以在接口實現中調用方法public void processAction(ActionEvent actionevent){clController.getTotal();}' – dratewka 2013-05-01 14:37:52

相關問題