title: Primefaces validate cell editing
body: <p>I'm using cell editor in Primefaces to update cells in a datatable. However I want to validate the input before I confirm the change.</p>
  
  <p>I have used <code>FacesContext.getCurrentInstance().validationFailed();</code> for this purpose but still getting the cell updated. </p>
  
  <p>This is how I'm implementing it:</p>
  
  <pre><code>&lt;p:dataTable value="#{bean.list}" var="var" id="table" editMode="cell" editable="true"&gt;
      &lt;p:ajax event="cellEdit" listener="#{bean.onCellEdit}" update="@form"/&gt;
      &lt;p:column headerText="Quantity"&gt;
          &lt;p:cellEditor&gt;
              &lt;f:facet name="output"&gt;
                   &lt;h:outputText value="#{var.quantity}"/&gt;
              &lt;/f:facet&gt;  
              &lt;f:facet name="input"&gt;
                     &lt;p:inputText value="#{var.quantity}"/&gt;
               &lt;/f:facet&gt;
          &lt;/p:cellEditor&gt;
      &lt;/p:column&gt;
  &lt;/p:dataTable&gt;
  </code></pre>
  
  <p>Bean Method:</p>
  
  <pre><code>public void onCellEdit(CellEditEvent event) {
      //validate new value
       if(!validate(event.getNewValue())){
          //if validation returned false stop updating the cell
          FacesContext.getCurrentInstance().validationFailed();
      }
  }
  </code></pre>
  
  <p>I want to stop updating the cell if the new value did not pass the validation, but the cell gets updated anyways. How can I solve this problem?</p>
  
  <p>PS: Primefaces 3.5</p>