title: Primefaces: Add a new row to datatable gives error: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled
body: <p>I have a datatable where I want to add a new row. When doing so I get the following error
  javax.servlet.ServletException: DataModel must implement org.primefaces.model.SelectableDataModel when selection is enabled.</p>
  
  <p>How can I solve my problem?</p>
  
  <p>This is in my xhtml </p>
  
  <pre><code>&lt;h:commandLink  action="#{workOrderDetail.addOrderItem}" &gt;
          &lt;img src="${path.staticRootUrl}images/add.png" border="0" alt="${msg.workorderdetail_neworderitem}" title="${msg.workorderdetail_neworderitem}"/&gt;
       &lt;/h:commandLink&gt;
  &lt;p:dataTable styleClass="ptable100" id="orderItems" var="orderItem" value="#{workOrderDetail.orderItems}" width="100%" height="200" widgetVar="results"
       emptyMessage="#{msg.all_lists_no_records_found}" selection="#{workOrderDetail.selectedOrderItem}" selectionMode="single" onRowSelectUpdate=":detail:sub"
       rowKey="#{orderItem.id}"
  &lt;p:ajax event="rowSelect"  update=":detail:sub" /&gt;
  </code></pre>
  
  <p>and this is my bean code</p>
  
  <pre><code>List&lt;IMWSOrderItem&gt; orderList = null;
  public void addOrderItem() throws MWSException {
    IMWSOrderItem newOrderItem = getWorkOrder().getMWSOrder().getMWSOrderItem_Set().getNewMWSOrderItem();      
    getWorkOrder().getMWSOrder().getMWSOrderItem_Set().addMWSOrderItem(newOrderItem);
    orderList = null;   
  }
  public List&lt;IMWSOrderItem&gt; getOrderItems() throws MWSException {
    if (orderList == null) {
       orderList = new ArrayList(Arrays.asList(getWorkOrder().getMWSOrder().getMWSOrderItem_Set().getMWSOrderItems()));
    }
    return orderList;
  }
  public IMWSOrderItem getSelectedOrderItem() {
    return selectedOrderItem;
  }
  public void setSelectedOrderItem(IMWSOrderItem newSelectedOrderItem) {
    this.selectedOrderItem = newSelectedOrderItem;
  }
  </code></pre>