有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java在添加此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);

有什么问题吗


共 (1) 个答案

  1. # 1 楼答案

    问题在于actionListenerbinding属性的值——它应该指向实现ActionListener接口的对象——而不是像您的情况那样的方法调用

    根据JSF规范:

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