I have a simple requirement that someone else ought to have had before, but cannot find a solution in the forums.
I have a datatable with in editMode="cell", in which only the first column editable. When the cell is edited and loses focus, the AJAX event gets fired properly. The logic in that backing bean method changes rest of the data for that row, based on the input. At this point I want to show the updated data in that row. But no matter what I have tried, it does not show the updated data in the row/table. (I can verify that the data has indeed changed in the list by switching to another screen and coming back to it).
I tried partialSubmit="true", process="@this", forcing update of the individual cells using RequestContext, updating the entire datatable with and without an enclosing form etc. - none works. In each case, I am making sure that I am referring to the appropriate ID generated in the pattern ":formID:componentID". I also made sure that there are no JavaScript errors on the page.
Relevant JSF code:
Code: Select all
<h:form id="badSsnForm">
<p:dataTable id="badSsnsList" value="#{ssnXRefMBean.ssnXRefInfo.badSsnTEs}"
var="item" rowKey="item.ssn" editable="true" editMode="cell">
<p:ajax event="cellEdit" listener="#{ssnXRefMBean.onCellEdit}" update=":badSsnForm:badSsnsList,:growlMsg"/>
<f:facet name="header">
<h:outputText value="Bad SSNs"/>
</f:facet>
<p:column>
<f:facet name="header">
<h:outputText value="SSN"/>
</f:facet>
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{item.ssn}" />
</f:facet>
<f:facet name="input">
<p:inputMask id="itemSsn" value="#{item.ssn}" mask="999-99-9999" converter="SsnConverter"
title="Please enter 9 digits" size="12" autocomplete="off" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="TE SUID"/>
</f:facet>
<h:outputText id="teSuid" value="#{item.teSuid}"/>
</p:column>
<p:column >
<f:facet name="header">
<h:outputText value="Name"/>
</f:facet>
<p:outputLabel id="dispName" value="#{item.displayName}"/>
</p:column>
<!-- other columns -->
</p:dataTable>
</h:form>
cellEdit event handler in the backing bean:
Code: Select all
public void onCellEdit(CellEditEvent event) {
int index = event.getRowIndex();
String oldSsn = (String) event.getOldValue();
String newSsn = (String) event.getNewValue();
// Other logic to get the info for newSsn from the EJB
ssnXRefInfo.getBadSsnTEs().set(index, updatedTE);
// Tried to update individual cells with the following, that also doesn't work
// RequestContext requestContext = RequestContext.getCurrentInstance();
// requestContext.update("badSsnForm:badSsnsList:" + index + ":teSuid");
// requestContext.update("badSsnForm:badSsnsList:" + index + ":dispName");
}
Thanks
NN