I have an issue with the Cell Edit mode of a data table.
I only have a single cell per row that needs to be able to be edited.
I can edit it, but the changed value is not then displayed. Although, oddly enough, when I re-edit the same cell, the changed value is displayed.
The onChange
call is made to the server side bean, but the old and new values are both the same.
Basing the example similar to the showcase one, the growl message is not displayed.
This is the full xhtml
code:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- jsf:pagecode language="java" location="/src/main/java/pagecode/ManageIniFile.java" --><!-- /jsf:pagecode -->
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
template="theme/ccd.xhtml">
<ui:define name="body-content">
<center>
<h:form styleClass="form" id="form">
<p:growl id="messages" showDetail="true"/>
<h:panelGrid columns="1" cellpadding="20" width="50%">
<h1 class="title ui-widget-header ui-corner-all">Manage Environments</h1>
<div class="entry">
<p:tabView id="tabView" var="section" value="#{iniFile.sections}">
<p:tab id="sectionTab" title="#{section}">
<p:dataTable var="entry" value="#{iniFile.getEntries(section)}" editable="true" editMode="cell">
<p:ajax event="cellEdit" listener="#{pc_ManageIniFile.onCellEdit}" update=":form:messages" />
<p:column headerText="Entry">
<h:outputText value="#{entry.entry}" />
</p:column>
<p:column headerText="Value">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{entry.value}" /></f:facet>
<f:facet name="input"><p:inputText value="#{entry.value}" style="width:46%" label="Value" /></f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
</p:tab>
</p:tabView>
<h:panelGrid columns="2" width="50%">
<h:commandButton type="submit" value="Add Environment" styleClass="loginButton" id="addSection" />
<h:commandButton type="submit" value="Save Environment" styleClass="loginButton" id="saveFile" />
</h:panelGrid>
</div>
</h:panelGrid>
</h:form>
</center>
</ui:define>
</ui:composition>
The pagecode bean, that has the onCellEdit() method is as follows:
public void onCellEdit(CellEditEvent event)
{
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
System.out.println("oldValue=" + oldValue);
System.out.println("newValue=" + newValue);
if (newValue != null && !newValue.equals(oldValue))
{
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
Irrespective of what I'm editing, oldValue
always equals newValue
. :cry:
Can anyone who knows better than I offer any suggestions?
As once this page works, the app is pretty much done.
Thanks,
-Chris
As a follow up, I've tried Mojarra 2.2.6 and MyFaces 2.2.2 with PF 4 and 5.0.RC1. The same result. I don't think that the cell editing works inside a tabView. I have managed to get the showcase example working, so I know that cell editing works on WAS 8.5.5.1 and MF 2.2.2.