title: Primefaces datatable: Unable to retrieve selected rows and selection get lost with pagination
body: <p>I am using primefaces datatable for checkbox based selection and try to implement <a href="http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf" rel="nofollow">given example</a>. They used Model say, <strong>userModel</strong> which could implement SelectableDataModel interface. I don't want to use model so I used <strong>rowKey</strong> for this purpose.</p>
  
  <p>E.g </p>
  
  <p>datatable.xhtml </p>
  
  <pre><code>&lt;p:dataTable id="table" var="item" value="#{userBean.allItems}"
         paginatorPosition="bottom" paginator="true" rows="3"
         selection="#{userBean.selectedItems}" rowKey="#{item[0]}"&gt;
  
         &lt;p:column selectionMode="multiple"/&gt;
  
         &lt;p:columns value="#{userBean.itemColHeader}" columnIndexVar="colIndex" var="colName" &gt;
         &lt;f:facet name="header" &gt;
             &lt;h:outputText value="#{colName}"/&gt;
         &lt;/f:facet&gt;
             &lt;h:outputText value="#{item[colIndex]}"/&gt;
         &lt;/p:columns&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>Here, </p>
  
  <p><code>allItems = ArrayList&lt;ArrayList&lt;String&gt;&gt;</code></p>
  
  <p><code>selectedItems = ArrayList&lt;ArrayList&lt;String&gt;&gt;</code></p>
  
  <p><code>selectedItems = ArrayList&lt;String&gt;</code></p>
  
  <p>userBean.java</p>
  
  <pre><code>@ManagedBean(name="userBean")
  @ViewScoped
  public class userBean implements SelectableDataModel {
  
      private ArrayList&lt;ArrayList&lt;String&gt;&gt; selectedItems;
  
      public ArrayList&lt;ArrayList&lt;String&gt;&gt; getSelectedItems() {
          return selectedItems;
      }
  
      public void setSelectedItems(ArrayList&lt;ArrayList&lt;String&gt;&gt; selectedUsers) {
          this.selectedItems = selectedItems;
      }
  }  
  </code></pre>
  
  <p>My problem:</p>
  
  <pre><code>1) When I select mulitple rows, selectedUsers remains empty.
  2) After selecting next page, previous selection get lost. 
  </code></pre>
  
  <p>I went through @BelusC <a href="http://balusc.blogspot.in/2006/06/using-datatables.html" rel="nofollow">blog</a> and found that binding is possible solution but unable to solve my problem with his instructions. Is converter needed..? Is there any thing wrong with my approach. Thanks</p>
  
  <p><strong>Update:1</strong></p>
  
  <p>The reason behind using Arraylist of Arraylist(<strong>allItems</strong>) is only to make datatable generic. I need not to bother about the no of columns while drawing datatables. That is why I want to retrieve the selected items which should not depend on object(<a href="http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf" rel="nofollow">like</a>: car[ ] selectedcars) </p>