2013-05-01 70 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的對象。

相關問題