I have been banging my head trying to figure this out all morning and cannot get it to work. Basically, I cannot get a new dataTable value from a cellEdit event via PrimeFaces.
Here is my XHTML page:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<h:form id="httpPolicyForm">
<p:dataTable id="httpTable" var="row" value="#{httpPolicyBean.rows}" editable="true" editMode="cell">
<f:facet name="header">
HTTP Policy
</f:facet>
<p:ajax event="cellEdit" listener="#{httpPolicyBean.onCellEdit}" update=":httpPolicyForm:httpTable" />
<p:column headerText="Property">
<h:outputText value="#{row.name}" />
</p:column>
<p:column headerText="Value">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{row.value}" /></f:facet>
<f:facet name="input"><p:inputText value="#{row.value}" style="width:100%"/></f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</h:form>
And here is my even listener method:
public void onCellEdit(CellEditEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
printRowValues();
if(newValue != null && !newValue.equals(oldValue)) {
logger.debug("Old: " + oldValue + ", New:" + newValue);
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
The method is invoked but the value of newValue is always the old value. Also, the table is never updated with the new value. However, if I click on the cell again to edit the value again it pulls up the new value. I am not sure what I am doing wrong. Please help me figure this out.
The bean is SessionScoped.