1 Reply Latest reply on Nov 12, 2009 6:02 PM by jguglielmin

    Problem with pagination

    ckraus

      Hi guys,


      I'm a seam newby and I'm facing a big problem, while using Seam pagination for a @DataModel.
      I am using an icefaces version 1.8.1 on Seam 2.2.0 with hibernate on jboss 4.2.4.


      What I try to implement, is a selectable list of 'permissions' with pagination. the permissions should be assigned to a 'role' by checking the specific list elements. To make list elements selectable for the user, I use the <ice:selectManyCheckbox> component with layout 'spread'.


      Here is the code for the datatable component:



      <ice:selectManyCheckbox id="permCheck" value="#{roleHome.instance.permissions}" layout="spread" required="true" partialSubmit="true">
           <s:selectItems value="#{permissions}" var="_permCheck"/>
           <s:convertEntity/>
      </ice:selectManyCheckbox>
      <ice:dataTable id="selectPermissionTable" value="#{permissions}" var="_permission" resizable="true" varStatus="permStatus" rowClasses="content_row_even content_row_odd">
           <ice:column>
               <f:facet name="header">
               <ice:outputText value="#messages['form.table.column.selected']}"/>
               </f:facet>
               <ice:checkbox for="permCheck" index="#{permStatus.index}"/>
           </ice:column>
           ...
      </ice:datatable>



      and the pagination part:



      <ice:panelGroup styleClass="center_Paginator">
          <s:link id="firstPermissions" view="/administration/role/Role.xhtml" disabled="#{not permissionList.previousExists}" action="#{permissionList.setFirstResult(0)}">
              <ice:graphicImage value="/stylesheet/css-images/arrow-first_#{permissionList.previousExists ? '4591a1' : '4591a1-dis'}.gif"/>
          </s:link>
          <s:link id="previousPermissions" view="/administration/role/Role.xhtml" disabled="#{not permissionList.previousExists}" action="#{permissionList.setFirstResult(permissionList.previousFirstResult)}">
              <ice:graphicImage value="/stylesheet/css-images/arrow-previous_#{permissionList.previousExists ? '4591a1' : '4591a1-dis'}.gif"/>
          </s:link>
          <s:link id="nextPermissions" view="/administration/role/Role.xhtml" disabled="#{not permissionList.nextExists}" action="#{permissionList.setFirstResult(permissionList.nextFirstResult)}">
              <ice:graphicImage value="/stylesheet/css-images/arrow-next_#{permissionList.nextExists ? '4591a1' : '4591a1-dis'}.gif"/>
          </s:link>
          <s:link id="lastPermissions" view="/administration/role/Role.xhtml" disabled="#{not permissionList.nextExists}" action="#{permissionList.setFirstResult(permissionList.lastFirstResult)}">
              <ice:graphicImage value="/stylesheet/css-images/arrow-last_#{permissionList.nextExists ? '4591a1' : '4591a1-dis'}.gif"/>
          </s:link>
      </ice:panelGroup>



      Here is the code for the @Factory method in my RoleHome (extends org.jboss.seam.framework.EntityHome<Role>)




      @DataModel
      protected List<Permission> permissions;
       
      @DataModelSelection
      @Out(required = false)
      protected Permission selPermission;
       
      @Factory(value = "permissions")
      @Observer(value = "permissionModified", create = false)
      @SuppressWarnings("unchecked")
      public void retrieveAllPermissions()
      {
          permissionList.refresh();
          permissions = permissionList.getResultList();
      }



      Now to my problem...
      The pagination works perfect. It displays 10 elements, like configured in the PermissionList.java.
      When selecting permissions, for example the permissions 'read' and 'write', the objects are added to the roleHome.instance.permissions list. Clicking the button for the next page of the list, the next 10 results are displayed correctly. The roleHome.instance.permissions still contains the before selected elements ('read' and 'write'). But when selecting a permission (e. g. 'modify') on the second page, the roleHome.instance.permissions only contains the last selected one ('modify') and the before selected elements are lost.
      When I click the previous button and return to the first page of the list, no element is selected, but the 'read' and 'write' permissions should rather be checked.


      I am quite confused and I don't know, what I'm doing wrong. Hope anyone can think of my problem. Tell me, if you need any further information.


      Many thanks in advance


      Chris





        • 1. Re: Problem with pagination
          jguglielmin

          Not sure exactly what modify is supposed to do, but if you are thinking that something is supposed to change regarding your datamodel, the factory annotation will create object if the value of the annotated object is null.


          Is the permission list supposed to be the same list throughout?  Is it supposed to change? (ie: what should the scope of the list be?). It sure sounds like a scope problem, so perhaps you should review this.


          There are also considerations when you use ajax-enabled components with injection/outjection.  See the setEventPhase component for times when you have 2 partialSubmits on ajax-enabled components within the same form.


          Hope this helps.