我正在尝试使用单元格编辑来实现primefaces数据表。
<p:dataTable id="table" var="data" value="#{bean.liste}"
editable="true"
editMode="cell"
widgetVar="cellInter"
styleClass="hovered striped table tblDataTable" >
<p:ajax event="cellEdit" listener="#{bean.onCellEdit}" />
<p:column sortBy="#{data.type}" filterBy="#{data.type}" filterMatchMode="contains" >
<f:facet name="header">
<span class="nomColonneTab" >Type </span>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<p:outputLabel value="#{data.type}"/>
</f:facet>
<f:facet name="input">
<h:inputText value="#{data.type}" />
</f:facet>
</p:cellEditor>
</p:column>
但是当我点击数据表来更改类型的值时它不会改变
这是我的功能:
public void onCellEdit(CellEditEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if (newValue != null && !newValue.equals(oldValue)) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}