【问题标题】:I get errors when i add this ActionListener添加此 ActionListener 时出现错误
【发布时间】:2013-05-01 08:56:54
【问题描述】:

我有以下代码:

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

当我添加 &lt;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);

可能是什么问题?

【问题讨论】:

  • 我想要的是当我点击commandButton时调用两个方法
  • 您错过了堆栈跟踪的顶部。 “... at ...”行位于描述异常的最重要的第一行之后。

标签: java hibernate jsf


【解决方案1】:

问题出在actionListenerbinding 属性的值上——它应该指向一个实现ActionListener 接口的对象——而不是你的情况下的方法调用。

来自 JSF 规范:

计算结果为实现 javax.faces.event.ActionListener 的对象的值绑定表达式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 1970-01-01
    • 2019-09-25
    相关资源
    最近更新 更多