1 Reply Latest reply on May 11, 2010 6:19 PM by Rob Pridham

    Paginated checkboxes bound to next page's data

    Rob Pridham Newbie

      I'm trying to add checkboxes to my data table. The data table is paginated; that is, the first page shows 25 results, you browse to the next Seam page, get another 25 and so on. Specifically this is:


      /datatable.seam?firstResult=0
      /datatable.seam?firstResult=25
      /datatable.seam?firstResult=50



      and so on.


      The code I have in the table is:


      <h:selectBooleanCheckbox value="#{bean.selectionMap[_data.id]}"/>
      <h:outputText value="(#{_data.id})"/>



      At the bottom of this page, I have a link:


      <h:commandLink action="#{bean.pageChangeSubmit}" value="Submit"/>



      You can see that the checkbox values are bound to a map, as per many examples out there, which has the following:


          Map<Long, Boolean> selectionMap = new TreeMap<Long, Boolean>();
      
          public Map<Long, Boolean> getSelectionMap()
          {
              return selectionMap;
          }
          
          public void setSelectionMap( Map<Long, Boolean> map ) 
          {
              this.selectionMap = map;
          }




      So - I visit the first page. This puts out 25 checkboxes, with the numbers 1-26 next to it, matching the documents. This is correct.


      I click some checkboxes, click the Submit button, and in debug mode, go into the action and examine the map.


      The map is now populated with 25 entries. However the keys are for the checkboxes on the next page, 27-51! Therefore what is being stored is offset by a page.


      I have no idea how this can be happening. I tried various alternatives like ignoring the map and binding straight to a 'selected' property on the data bean - same problem.


      Any pointers?


      Cheers!