0 Replies Latest reply on Mar 12, 2009 1:34 PM by bobgee

    defining resultSet paging from the webcontent side

      Hi there,

      I read the seam docs, "Seam in Action", researched a lot, but didn't get the clue.
      It's about defining the number of result records per page (EntityQuery.setMaxResults()) on the webcontent side, i. e. in the webcontent subproject (1 of the 4 project generated by the Seam wizard), not in the *List bean.
      Preferred defined on a global basis in one place for all \*List.xhtml pages in my web project.

      I cannot apply setMaxResults() in the constructor of my *List bean cause I need the whole resultset on another page (edit page) for filling a SelectOneMenu.

      I read about the opportunity to define a query in components.xml like this:
      <framework:entity-query scope="conversation" name="printerList" ejbql="select printer from Printer printer"
      max-results="10"/>

      This way of defining a query in xml has limitations. Problems/Questions:
      - seems one cannot use xml definition if there are linked tables (e.g. @OneToMany), e. g.
      ejbql="select printer from Printer printer join printer.manufacturer manufacturer". I get an error when accessing an entity member of the queried entity: value="#{printerList.manufacturer.name}" => "Property 'manufacturer' not found on type"
      Dito with value="#{printerList.printer.manufacturer.name}"
      ?or I did something wrong?

      Seems I only can define the query in a List bean and define members to getters for printer and manufacturer. Am I right?

      - How would I pass the maxResults property to my List bean? In the first call of the *list.seam I have no URL parameter (only when advancing to the next page - if parameter defined in .page.xml), and sure it's not the right way to add a maxResult parameter to all list links in my menu.

      - need a long running conversation to maintain the resultSet pointer (nextFirst etc.)??
      scope="conversation" doesn't work, I stay on the first page.


      - calculating current page number
      I derive my individual entity List beans from my extened EntityQuery named ExtendedEntityQuery which adds a method getActivePage (this cannot be calculated in the view via an EL expression).

      public int getActivePage() { 
        Integer fr = getFirstResult(); 
        Integer mr = getMaxResults();
        if (fr == null) {
          fr = 0;
        }
        if (mr != null) { 
          return (fr / mr) + 1; 
        }
        return 0; 
      }

      ?How can I define another class for EntityQuery in the xml?
      Or how do you show the current page number?

      Thanks for your answers!

      Greets, Robert