简体   繁体   English

rich:column sortBy没有正确排序

[英]rich:column sortBy doesn't sort properly

This was the original code generated by seam-gen (2.2.0) 这是seam-gen(2.2.0)生成的原始代码

    <h:column>
        <f:facet name="header">
            <ui:include src="/layout/sort.xhtml">
                <ui:param name="entityList" value="#{userList}"/>
                <ui:param name="propertyLabel" value="Name"/>
                <ui:param name="propertyPath" value="user.name"/>
            </ui:include>
        </f:facet>
        <h:outputText value="#{_user.name}"/>
    </h:column>

We liked the sorting capabilities and hence we included rich:column sortBy, but sorting is incorrect (across paginated pages it lost the sorting capability, since the sorting parameters were not sent on page navigation), if we don't use /layout/sort.xhtml inside f:facet. 我们喜欢排序功能,因此我们包含了rich:column sortBy,但是排序是不正确的(如果我们不使用/ layout / sort,则在分页页面中它会丢失排序功能,因为排序参数不在页面导航上发送) .xhtml里面的f:facet。

                <rich:column sortBy="#{_user.name}">
                    <f:facet name="header">Name</f:facet>
                    <h:outputText value="#{_user.name}"/>
                </rich:column>

How do we get the same functionality as before using rich:column sortBy 我们如何获得与使用rich之前相同的功能:column sortBy

To you the sortBy in the same way seam-gen generates sorting for you, you need to generate the complete list, and not a part of the list as the entityframework of seam does it. 对于sortBy ,就像seam-gen为你生成排序一样,你需要生成完整的列表,而不是作为seam的实体框架的列表的一部分。

ie: 即:

List allResults = entityManager.createQuery("From X").getResultList();

Now if you just for testing try to use this list in your sortBy you will se it will work as you except. 现在,如果你只是为了测试尝试在你的sortBy中使用这个列表,你会发现它将像你一样工作。 However, the downside is that this will load all result and put in memory. 但是,缺点是这将加载所有结果并放入内存。 This might not be what you want. 这可能不是你想要的。

You should however use this together with some search result, so it is already filtered based on some user input. 但是,您应该将此与一些搜索结果一起使用,因此它已根据某些用户输入进行过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM