0 Replies Latest reply on Sep 25, 2006 5:24 PM by Monkey Den

    Extended PersitenceContext

    Monkey Den Newbie

      I'm sure there is a pretty simple answer to this but here goes...

      I've implemented a variation of the Seam Messages example. I've made it a search + results screen. On the initial submit, I have a SFSB which does the query and returns the results (java.util.List) to the same screen. This works great. I have also implemented pagination, to display a specifed # of rows at one time. The problem is "items" does not persist across requests for pagination. Inside the scrollNext() method this List is null. The question is, is there anything in particular you must do (annotate? something else?) to allow a data member to persist across multiple requests? Thanks for any assistance.

      Here is the code:

      @Stateful
      @Name("usersearch")
      public class UserSearchAction implements UserSearch {
      ....
       @DataModel
       private List items;
      ...
      
       public String search() {
       ...
       items = query.getResultList();
       rowCount = items.size();
       ...
       }
      
       public void scrollNext() {
       firstRowIndex += rowsPerPage;
       if (firstRowIndex >= rowCount) {
       firstRowIndex = rowCount - rowsPerPage;
       if (firstRowIndex < 0) {
       firstRowIndex = 0;
       }
       }
       }


      JSF Code:
      FYI: the boolean methods used by the deleted attribute are also working fine

      <h:dataTable var="user"
       value="#{usersearch.items}"
       styleClass="resultsTable" rowClasses="odd,even"
       first="#{usersearch.firstRowIndex}"
       rows="#{usersearch.rowsPerPage}" >
      ...PRINT THE FIELDS
      </h:dataTable>
      
      <h:commandButton value="<<" disabled="#{usersearch.scrollFirstDisabled}" action="#{usersearch.scrollFirst}" />
      
      <h:commandButton value="<" disabled="#{usersearch.scrollPreviousDisabled}" action="#{usersearch.scrollPrevious}" />
      
      <h:commandButton value=">" disabled="#{usersearch.scrollNextDisabled}" action="#{usersearch.scrollNext}" />
      
      <h:commandButton value=">>" disabled="#{usersearch.scrollLastDisabled}" action="#{usersearch.scrollLast}" />