title: Primefaces - how to get the column of a CellEditEvent
body: <p>I am using primefaces 4.</p>
  
  <p>I am using an editable table and when I edit a cell, a listener method is called passing a CellEditEvent</p>
  
  <p>Like this</p>
  
  <pre><code>public void onCellEdit(CellEditEvent event) {  
      /*
       * The rowIndex here can be changed according to the sorting/filtering.
  
       * FilteredData starts as null, but primefaces initializes it, so you 
       * don't have to check for NPE here
       */
      int alteredRow = event.getRowIndex();
      UIColumn o = event.getColumn();
  
      System.out.println(this.filteredData.get(event.getRowIndex()).get(columns.get(0)));
  }  
  </code></pre>
  
  <p>So far, so good.</p>
  
  <p>The event has a getRowIndex()</p>
  
  <p>But it does not have a getColumnIndex().</p>
  
  <p>Instead, it has a getColumn() method that returns a UIColumn object.</p>
  
  <p>The problem is, while debugging, I could not find a way to get any column information (name, id, etc)</p>
  
  <p>I can hack the column to have some unique ID like this</p>
  
  <pre><code> &lt;p:ajax event="cellEdit" listener="#{myMB.onCellEdit}"/&gt;
   &lt;c:forEach items="#{myMB.columns}" var="column" varStatus="loop"&gt;
  
      &lt;p:column id="col#{loop.index}" headerText="#{column}" sortBy="#{column}" filterBy="#{column}" filterMatchMode="contains"/&gt;
  
        &lt;p:cellEditor&gt;
  
         &lt;f:facet name="output"&gt;
          &lt;h:outputText value="#{dataRow[column]}" /&gt;
         &lt;/f:facet&gt;
  
         &lt;f:facet name="input"&gt;
          &lt;p:inputText value="#{dataRow[column]}"  /&gt;
         &lt;/f:facet&gt;
  
      &lt;/p:cellEditor&gt;     
  
      &lt;/p:column&gt;
  
   &lt;/c:forEach&gt;               
  </code></pre>
  
  <p>But still I can't find a way to retrieve the column id from the CellEditEvent</p>
  
  <p>So, assuming that a cell is something that has a row and a column, I have to ask</p>
  
  <p><strong>How do I retrieve the column of an edited cell in a CellEditEvent?</strong></p>
  
  <p>ps. I feel I am missing something, because no one would create a cell event without providing the row and the column, right?</p>
  
  <p>update - it seems I can get the ID like</p>
  
  <pre><code>org.primefaces.component.column.Column o = (org.primefaces.component.column.Column)event.getColumn();
  </code></pre>
  
  <p>still, this seems like a hack for me. I am still interested in more elegant solutions for this ;-)</p>