gpt4 book ai didi

java - 添加此 ActionListener 时出现错误

转载 作者:行者123 更新时间:2023-12-02 07:03:58 25 4
gpt4 key购买 nike

我有以下代码:

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

可能是什么问题?

最佳答案

问题出在 actionListenerbinding 属性的值上 - 它应该指向一个实现 ActionListener 接口(interface)的对象 - 而不是一个方法调用与您的情况相同。

来自 JSF 规范:

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

关于java - 添加此 ActionListener 时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16315341/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com