I'm experimenting with DataTable - Cell Editing as shown in PrimeFaces showcase. I've modified the Facelets code as consequence of this question: primefaces in-cell-editing not update data in database because the <p:ajax event="cellEdit"> didn't update the entire data table.
<h:form id="form">
<p:outputPanel id="testContainer" deferred="true">
<p:growl id="messages" showDetail="true" />
<p:remoteCommand name="onCellEdit" action="#{articlesbean.onCellEdit()}" update=":form:messages" />
<p:dataTable id="cars" var="car" value="#{articlesbean.LMatpilotaccess1}" editable="true" editMode="cell" widgetVar="carsTable" update=":cars">
<p:ajax event="cellEdit" oncomplete="onCellEdit()" />
...
</p:dataTable>
</p:outputPanel>
</h:form>
The remote command action method is definied as follows:
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);
}
}
However, this method is never invoked and the following exception is thrown:
javax.el.MethodNotFoundException: Method not found: [email protected]()
When I remove the CellEditEvent argument, then it works. But I actually need the old and the new value. How can I proceed?
Try this
And
You won't be able to perform the
!newValue.equals(oldValue)test comparison but you will be able to obtain your answer.Forget the
p:remoteCommandas outside thep:dataTableyou have not the 'desired'CellEditEvent.If for the same table, you have to show some calculations based in this cell, you should call it from a p:remoteCommand. Just add
oncomplete="onCellEditTableComplete()"and do the update from outside the table