2013-05-01 141 views
0

我有下面的代码:我得到的错误,当我加入这个ActionListener的

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

当我添加<f:actionListener binding="这一点,给了以下错误:

at com.sun.faces.facelets.el.TagValueExpression.getValue(TagValueExpression.java:114) 
    at com.sun.faces.facelets.tag.jsf.core.ActionListenerHandler$LazyActionListener.processAction(ActionListenerHandler.java:112) 
    at javax.faces.event.ActionEvent.processListener(ActionEvent.java:88) 
    at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:769) 

这是我getTotal功能:

List<CustomerPayment> total = null; 
     try { 
      org.hibernate.Transaction tx = session.beginTransaction(); 
      Query q = session.createQuery("SELECT SUM(amount) from CustomerPayment where DATE like '%"+year+"' GROUP BY type"); 
      total = (List<CustomerPayment>) q.list(); 
     } catch (Exception e) { 
      e.printStackTrace(); 
     } 

     return totalDataTable = new ListDataModel(total); 

可能是什么问题?

+0

我想要的是当我点击commandButton时调用两种方法 – user2326472 2013-05-01 08:59:34

+1

您已经错过了堆栈跟踪的顶部。 “... at ...”这行代表的是描述这个例外的第一条,也是最重要的一行。 – 2013-05-01 09:12:16

回答

2

问题出在actionListenerbinding属性值 - 它应指向一个实现接口的对象 - 而不是方法调用,就像你的情况一样。

从JSF规格:

值绑定表达式,其值实现javax.faces.event.ActionListener的对象。