为什么我不能调用这个功能?

时间:2013-05-01 13:30:22

标签: java jsf

 <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)

1 个答案:

答案 0 :(得分: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标签