title: Primefaces DataTable - selection not working property
body: <p>I have a DataTable from the context menu to delete items DataTable, but when you get to this deleteting, I haven't selected a row as parameter removal method. Works only with a few clicks of the line. I think this is an error in the selection, but I can not find this error. 
  Can somebody help me with this?</p>
  
  <pre><code>&lt;ui:composition template="../adminTemplates/layout.xhtml"
      xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"&gt;
      &lt;ui:define name="content"&gt;
          &lt;h:form id="form"&gt;
              &lt;p:growl id="messages" showDetail="true" /&gt;
              &lt;p:contextMenu for="dataTable"&gt;
                  &lt;p:menuitem value="Delete" update=":form:dataTable"
                      icon="ui-icon-close" actionListener="#{roomMB.deleteRoom}" /&gt;
              &lt;/p:contextMenu&gt;
  
              &lt;p:dataTable id="dataTable" var="room" styleClass="DataTableRooms"
                  rowKey="#{room.room_id}" value="#{roomMB.roomList}" paginator="true"
                  rows="5" selection="#{roomMB.selectedRoom}" selectionMode="single"
                  paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                  rowsPerPageTemplate="5,10,15"&gt;
                  &lt;p:ajax event="rowEdit" listener="#{roomMB.onEdit}"
                      update=":form:messages, dataTable" /&gt;
                  &lt;p:ajax event="rowEditCancel" listener="#{roomMB.onCancel}"
                      update=":form:messages" /&gt;
                  &lt;p:column sortBy="number" filterBy="number" id="number"
                      headerText="Room Number"&gt;
                      &lt;p:cellEditor&gt;
                          &lt;f:facet name="output"&gt;
                              &lt;h:outputText value="#{room.number}" /&gt;
                          &lt;/f:facet&gt;
                          &lt;f:facet name="input"&gt;
                              &lt;h:inputText value="#{room.number}" /&gt;
                          &lt;/f:facet&gt;
                      &lt;/p:cellEditor&gt;
                  &lt;/p:column&gt;
                  &lt;p:column sortBy="capacity" filterBy="capacity" id="capacity"
                      headerText="Room Capacity"&gt;
                      &lt;p:cellEditor&gt;
                          &lt;f:facet name="output"&gt;
                              &lt;h:outputText value="#{room.capacity}" /&gt;
                          &lt;/f:facet&gt;
                          &lt;f:facet name="input"&gt;
                              &lt;h:inputText value="#{room.capacity}" /&gt;
                          &lt;/f:facet&gt;
                      &lt;/p:cellEditor&gt;
                  &lt;/p:column&gt;
  
                  &lt;p:column sortBy="room_description" filterBy="room_description"
                      id="room_description" headerText="Room Localization"&gt;
                      &lt;p:cellEditor&gt;
                          &lt;f:facet name="output"&gt;
                              &lt;h:outputText value="#{room.room_description}" /&gt;
                          &lt;/f:facet&gt;
                          &lt;f:facet name="input"&gt;
                              &lt;h:inputText value="#{room.room_description}" /&gt;
                          &lt;/f:facet&gt;
                      &lt;/p:cellEditor&gt;
                  &lt;/p:column&gt;
                  &lt;p:column style="width:6%" headerText="Edit"&gt;
                      &lt;p:rowEditor /&gt;
                  &lt;/p:column&gt;
                  &lt;f:facet name="footer"&gt;
                      &lt;p:commandButton value="New Room" oncomplete="newRoomDialog.show()"
                          icon="ui-icon-star" title="Creates new room" /&gt;
  
                  &lt;/f:facet&gt;
  
              &lt;/p:dataTable&gt;
          &lt;/h:form&gt;
  
  
          &lt;p:dialog header="Create New Room" widgetVar="newRoomDialog"
              resizable="false" id="newRoomDlg"&gt;
              &lt;h:form id="newRoomForm"&gt;
                  &lt;p:panelGrid id="displayNewRoom" columns="2" cellpadding="4"
                      style="margin:0 auto;"&gt;
                      &lt;h:outputText value="Number :"&gt;&lt;/h:outputText&gt;
                      &lt;p:inputText id="name" value="#{roomMB.number}" required="true"
                          requiredMessage="Please Enter room number" /&gt;
  
                      &lt;h:outputText value="Capacity :"&gt;&lt;/h:outputText&gt;
                      &lt;p:inputText value="#{roomMB.capacity}" required="true"
                          requiredMessage="Please Enter Capacity" /&gt;
  
                      &lt;h:outputText value="Room localization :"&gt;&lt;/h:outputText&gt;
                      &lt;p:inputText value="#{roomMB.room_description}" required="true"
                          requiredMessage="Please Enter room Description" /&gt;
  
                      &lt;f:facet name="footer"&gt;
                          &lt;p:commandButton value="Submit" actionListener="#{roomMB.addRoom}"
                              oncomplete=" handleSubmitRequest(xhr, status, args, 'newRoomDlg','newRoomForm');"
                              update=":form:dataTable, :growl" /&gt;
                          &lt;p:commandButton type="reset" value="Reset"&gt;&lt;/p:commandButton&gt;
                      &lt;/f:facet&gt;
                  &lt;/p:panelGrid&gt;
              &lt;/h:form&gt;
          &lt;/p:dialog&gt;
          &lt;p:growl id="growl" showDetail="true" life="5000" /&gt;
  
          &lt;script type="text/javascript"&gt;
              function handleSubmitRequest(xhr, status, args, dialogName,
                      formName) {
                  dialog = jQuery('#' + dialogName);
                  if (args.validationFailed) {
                      dialog.effect("shake", {
                          times : 3
                      }, 100);
                  } else {
                      clearForm(formName);
                      newRoomDialog.hide();
                      roomDialog.hide();
                  }
              }
              function clearForm(formName) {
                  jQuery('#' + formName).each(function() {
                      this.reset();
                  });
              }
          &lt;/script&gt;
  
      &lt;/ui:define&gt;
  &lt;/ui:composition&gt;
  </code></pre>