Openfaces:使用 hibernateCriterionBuilder 和数据表过滤器
我目前正在尝试构建一个页面,该页面将具有一个数据表,该数据表允许根据为每列设置的条件进行过滤。根据文档,openfaces hibernateCriterionBuilder 是使用 hibernate 实现此目的的最简单方法。构建器可以很好地进行排序,但是一旦通过过滤条件,它就会抛出错误:
严重:javax.el.ELException:/tools/orders/orderPicker.xhtml @24,168 value="#{orderPicker.orders}":org.hibernate.QueryException:无法解析属性:/tools/orders/orderPicker : pojo.订单
我所知,这是 hibernateCriterionBuilder 的一部分无法正确解析过滤数据,这让我怀疑我做错了什么。对构建器的调用如下所示:
Session session = resources.HibernateUtil.getSessionFactory().openSession();
Criteria criteria = HibernateCriterionBuilder.buildCriteria(session, pojo.Orders.class);
orders = criteria.list();
从下表中:
<o:dataTable value="#{orderPicker.orders}" var="item" customDataProviding="true" totalRowCount="#{orderPicker.rowCount}" pageSize="10">
<o:column sortingExpression="#{item.distId}" id="distId" >
<f:facet name="header">
distId
</f:facet>
<f:facet name="subHeader">
<o:dropDownFieldFilter condition="beginsWith" />
</f:facet>
<h:outputText value="#{item.distId}" />
</o:column>
</o:dataTable>
任何帮助或见解将不胜感激。
I am currently trying to build a page that will have a datatable that allows for filtering based on criteria set for each column. According to the documentation, the openfaces hibernateCriterionBuilder is the easiest way to accomplish this using hibernate. The builder works fine for sorting, but as soon as filtering criteria are passed it throws an error:
SEVERE: javax.el.ELException: /tools/orders/orderPicker.xhtml @24,168 value="#{orderPicker.orders}": org.hibernate.QueryException: could not resolve property: /tools/orders/orderPicker of: pojo.Orders
As far as I can tell this is a failure on part of the hibernateCriterionBuilder to properly parse the filtering data, which makes me suspect I am doing something wrong. The call to the builder is like so:
Session session = resources.HibernateUtil.getSessionFactory().openSession();
Criteria criteria = HibernateCriterionBuilder.buildCriteria(session, pojo.Orders.class);
orders = criteria.list();
From the following table:
<o:dataTable value="#{orderPicker.orders}" var="item" customDataProviding="true" totalRowCount="#{orderPicker.rowCount}" pageSize="10">
<o:column sortingExpression="#{item.distId}" id="distId" >
<f:facet name="header">
distId
</f:facet>
<f:facet name="subHeader">
<o:dropDownFieldFilter condition="beginsWith" />
</f:facet>
<h:outputText value="#{item.distId}" />
</o:column>
</o:dataTable>
Any help or insight would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为回答自己的问题而道歉,但我知道我做错了什么。当将 customDataProver 与过滤器一起使用时,您需要将过滤器的表达式属性定义为等于您尝试映射到的 hibernate 属性。
更改
为
使一切正常。
I apologize for answering my own question, but I figured out what I was doing wrong. When using customDataProver with filters, you need to define the expression attribute of the filter to be equal to the hibernate property you are trying to map to.
Changing
to
Made everything work just fine.