I'm trying to use the roweditor of PrimeFaces datatable and I have the problem that changing the value in the datatable the managed bean does not recognize the new value and the old remains.
I almost "cloned" the showcase of RowEditing and surprisingly not work me. I searched more posts and some say it may be a bug, but I replicated exactly the showcase example and it works. My version is PrimeFaces 5.0.
*.xhtml
<h:form id="frmExclos">
<p:growl id="mensajeGeneral3" sticky="false" showDetail="true"/>
<p:panel id="pnlCriteriExclusio" style="width: 425px" header="Criteris d'exclusió del pacient" widgetVar="pnlCriterisE">
<p:dataTable id="tblCriterisExclusioNia" var="itemCriterisExclusio" value="#{mbRCriteriExclusio.getCriterisExclusioNia(mbVMalignitatNia.personaAmbMalignitatNia.id)}" editable="true">
<p:ajax event="rowEdit" listener="#{mbRCriteriExclusio.onRowEdit}" update=":frmExclos:mensajeGeneral3" />
<p:ajax event="rowEditCancel" listener="#{mbRCriteriExclusio.onRowCancel}" update=":frmExclos:mensajeGeneral3" />
<p:column headerText="Observacions">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{itemCriterisExclusio.comentaris}"></h:outputText></f:facet>
<f:facet name="input"><p:inputText value="#{itemCriterisExclusio.comentaris}" label="Observacions"></p:inputText></f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:32px">
<p:rowEditor />
</p:column>
<f:facet name="footer" ><p:commandButton update="@this" icon="ui-icon-plusthick" value="Afegir criteri" oncomplete="PF('dlgAddCriterisExclusio').show()"/>
</f:facet>
</p:dataTable>
</p:panel>
</h:form>
Then, the fragment of the managed bean MbRCriteriExclusio.java :
@Named(value = "mbRCriteriExclusio")
@ViewScoped
public class MbRCriteriExclusio {
public void onRowCancel(RowEditEvent event) {
FacesMessage msg = new FacesMessage("Edit Cancelled", "" + ((MalignitatPersonaCriterisExclusioNia) event.getObject()).getComentaris());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
In the Msg getComentaris returns the initial value loaded in the datatable not the new value that I've edited! The code of the showcase is the same ..
thank you very much for your help
In case of rowCancel,it wont reflect the new value since you are cancelling out the changes. in this function public void onRowEdit(RowEditEvent event) you will be able to get modified value. Try this.