Openfaces:使用 hibernateCriterionBuilder 和数据表过滤器

发布于 2024-10-12 17:29:57 字数 1387 浏览 1 评论 0原文

我目前正在尝试构建一个页面,该页面将具有一个数据表,该数据表允许根据为每列设置的条件进行过滤。根据文档,openfaces hibernateCriterionBuilder 是使用 hibernate 实现此目的的最简单方法。构建器可以很好地进行排序,但是一旦通过过滤条件,它就会抛出错误:

严重:javax.el.E​​LException:/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

霓裳挽歌倾城醉 2024-10-19 17:29:57

我为回答自己的问题而道歉,但我知道我做错了什么。当将 customDataProver 与过滤器一起使用时,您需要将过滤器的表达式属性定义为等于您尝试映射到的 hibernate 属性。

更改

<o:dropDownFieldFilter condition="beginsWith" />

<o:dropDownFieldFilter condition="beginsWith" expression="distId" />

使一切正常。

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

<o:dropDownFieldFilter condition="beginsWith" />

to

<o:dropDownFieldFilter condition="beginsWith" expression="distId" />

Made everything work just fine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文