I get errors when i add this ActionListener

此生再无相见时 提交于 2019-12-18 09:50:28

问题


I have below code:

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

When i add <f:actionListener binding=" this it gives below errors:

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)

This my getTotal function:

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

What might be the problem?


回答1:


The problem is in the value of actionListener's binding attribute - it should point to an object implementing the ActionListener interface - not a method call as is in your case.

From the JSF spec:

Value binding expression that evaluates to an object that implements javax.faces.event.ActionListener.



来源:https://stackoverflow.com/questions/16315341/i-get-errors-when-i-add-this-actionlistener

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!