I use straight 4.
I use an editable table, and when I edit a cell, the listener method is called by passing CellEditEvent
Like this
public void onCellEdit(CellEditEvent event) {
int alteredRow = event.getRowIndex();
UIColumn o = event.getColumn();
System.out.println(this.filteredData.get(event.getRowIndex()).get(columns.get(0)));
}
So far so good.
The event has getRowIndex ()
But it does not have getColumnIndex ().
Instead, it has a getColumn () method that returns a UIColumn object.
The problem is that when debugging, I could not find a way to get information about the columns (name, identifier, etc.)
I can hack a column to have a unique identifier like this
<p:ajax event="cellEdit" listener="#{myMB.onCellEdit}"/>
<c:forEach items="#{myMB.columns}" var="column" varStatus="loop">
<p:column id="col#{loop.index}" headerText="#{column}" sortBy="#{column}" filterBy="#{column}" filterMatchMode="contains"/>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{dataRow[column]}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{dataRow[column]}" />
</f:facet>
</p:cellEditor>
</p:column>
</c:forEach>
But still I can't find a way to get the column id from CellEditEvent
So, assuming the cell is something that has a row and column, I should ask
How to get edited cell column in CellEditEvent?
. , - , , ?
update - , ,
org.primefaces.component.column.Column o = (org.primefaces.component.column.Column)event.getColumn();
, . : -)