title: Delete row in a PrimeFaces datatable
body: <p>I am using PrimeFaces 3.5 and I am implementing the <a href="http://www.primefaces.org/showcase-labs/ui/datatableContextMenu.jsf" rel="noreferrer">DataTable - ContextMenu</a> component.
  However, I want to delete a row by clicking on one cell in the row.</p>
  
  <p>My JSF page:</p>
  
  <pre><code>&lt;h:form id="form"&gt;
  
      &lt;p:growl id="messages" showDetail="true" /&gt;
  
      &lt;p:contextMenu for="productID" widgetVar="cMenu"&gt;
          &lt;p:menuitem value="Edit Cell" icon="ui-icon-search"
                      onclick="productService.showCellEditor();return false;" /&gt;
          &lt;p:menuitem value="Delete Row" icon="ui-icon-search"
                      onclick="productService.delete();return false;" /&gt;
      &lt;/p:contextMenu&gt;
  
      &lt;p:dataTable id="productID" var="product"
                   value="#{productService.getListOrderedByDate()}"
                   editable="true" editMode="cell" widgetVar="productTable"
                   paginator="true" rows="10"
                   paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                   rowsPerPageTemplate="5,10,15"&gt;
  
          &lt;f:facet name="header"&gt; Airbnb Product  &lt;/f:facet&gt;
  
          &lt;p:ajax event="cellEdit"
                  listener="#{productService.onCellEdit}"
                  update=":form:messages" /&gt;
  
          &lt;p:column headerText="id" style="width:15%"&gt;
              &lt;p:cellEditor&gt;
                  &lt;f:facet name="output"&gt;
                      &lt;h:outputText value="#{product.id}" /&gt;
                  &lt;/f:facet&gt;
                  &lt;f:facet name="input"&gt;
                      &lt;p:inputText value="#{product.id}" style="width:96%" /&gt;
                  &lt;/f:facet&gt;
              &lt;/p:cellEditor&gt;
          ...
          &lt;/p:column&gt;
      &lt;/p:dataTable&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>I have implemented a delete method in my service which should work. However, when I press the delete button in my context menu nothing happens. What could the cause of the problem be?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I did it like on the PF Page with:</p>
  
  <pre><code>public void delete() {
      log.info("Deleting data:");
      log.info(selectedRow.getId());
  //  productDAO.delete(selectedRow);
  
  }
  </code></pre>
  
  <p>and my datatable:</p>
  
  <pre><code>                &lt;p:contextMenu for="productID" widgetVar="cMenu"&gt;
                      &lt;p:menuitem value="Edit Cell" icon="ui-icon-search"
                          onclick="productService.showCellEditor();return false;" /&gt;
                      &lt;p:menuitem value="Delete" update="productID" icon="ui-icon-close"
                          actionListener="#{productService.delete}" /&gt;
                  &lt;/p:contextMenu&gt;
  
                  &lt;p:dataTable id="productID" var="product"
                      value="#{productService.getListOrderedByDate()}"
                      editable="true" editMode="cell" widgetVar="productTable"
                      paginator="true" rows="10"
                      paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                      rowsPerPageTemplate="5,10,15"
                      selection="#{productService.selectedRow}" selectionMode="single" rowKey="#{product.id}"&gt;
  </code></pre>
  
  <p>However, when I want to get the ID from selected Row I get a <code>NullPointerException</code>. I really appreciate your answer!!</p>