5 Replies Latest reply on Jan 14, 2008 5:31 PM by Pete Muir

    Keep Trinidad table sort order

    Alexander Seitz Newbie

      Hi,

      since Pete has done the wonderful integration of Trinidad in the seamdiscs example backed by a database query I have a question regarding the table sorting:

      It is now possible to sort columns of a Trinidad-table database-backed. If I do that and click on an entry of the table to load the corresponding data and show this information on the same page (not using ajax/partial page rendering!), the sort order of the table is lost :-(
      Is there any possibility to keep the sort order (save the sorting state of the Trinidad-table)?

      Thanks,

      Alexander

        • 1. Re: Keep Trinidad table sort order
          Pete Muir Master

          You need to place the EntityQuery in a longer scope to retain the sort criteria it holds (or somehow place the criteria in a longer scope).

          • 2. Re: Keep Trinidad table sort order
            Alexander Seitz Newbie

            Hi Pete,

            thanks for the answer. I do not fully unterstand how to do what you suggested.

            What I am doing is:

            Conversational SFSB

            @DataModel
            private List<Mitarbeiter> mitarbeiters;
            ...
            
            @Factory(value = "mitarbeiters")
             public void getMitarbeiterList() {
             Criteria c = ((HibernateSessionProxy) entityManager.getDelegate())
             .createCriteria(Mitarbeiter.class);
             c.addOrder(Order.desc("nachname"));
             mitarbeiters = c.list();
             }
            


            and in my template:

            <tr:table width="290px" value="#{mitarbeiters}" var="mitarbeiter" rows="5" styleClass="trTableDiv">
             <tr:column sortable="true" sortProperty="login">
             <f:facet name="header">Login</f:facet>
             <s:link value="#{mitarbeiter.login}" propagation="new"
             action="#{mitarbeiterMgr.selectMitarbeiter}">
             <f:param name="mitarbeiterId" value="#{mitarbeiter.id}" />
             </s:link>
             </tr:column>
            ...
            </tr:table>
            


            After clicking the link the same page loads again with the details of mitarbeiter, but the sort order of the table is gone.

            Ho do I access the EntityQuery or place the Criteria in another scope?

            Alexander

            • 3. Re: Keep Trinidad table sort order
              Pete Muir Master

              The code I wrote for backing the Trinidad table with a database query must be backed by an EntityQuery, not some arbitrary @DataModel

              • 4. Re: Keep Trinidad table sort order
                Alexander Seitz Newbie

                @Pete:
                Oh yes, sorry! I just realized that I need an EntityQuery to make the database backing work. The template then uses the entityQuery.dataModel...

                One more question:
                In our project we are working with org.hibernate.search.FullTextQuery. Is there any way to translate the FulltextQuery to an EntityQuery so that paging/sorting works database backed for the fulltextSearch-results?

                Thanks!

                Alexander