views:

444

answers:

1

This was the original code generated by 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="#{_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

+1  A: 

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.

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. 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.

Shervin
No, I am not interested in loading all the entities in memory as it defeats the notion of paginating entries. We would still want to rely on the EntityQuery framework but the rich:sortBy feature doesn't set any of those parameters needed by the entity query framework.
Kalpana
Yes because that is not how the `rich:sortBy` is implemented.You will need to either extend `rich:sortBy` or change the css so that it looks and behaves the same way as the `rich:sortBy`
Shervin