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. The changed value is not then displayed. Although, oddly enough, when I re-edit the same cell, the changed value is displayed again.
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:
Code: Select all
<?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>
Code: Select all
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);
}
}
Can anyone who knows better than I offer any suggestions?
As once this page works, the app is pretty much done.
Thanks,
-Chris