【发布时间】:2013-11-17 12:54:45
【问题描述】:
我正在试验 DataTable - Cell Editing,如 PrimeFaces 展示中所示。由于这个问题,我修改了 Facelets 代码:primefaces in-cell-editing not update data in database,因为<p:ajax event="cellEdit"> 没有更新整个数据表。
<h:form id="form">
<p:outputPanel id="testContainer" deferred="true">
<p:growl id="messages" showDetail="true" />
<p:remoteCommand name="onCellEdit" action="#{articlesbean.onCellEdit()}" update=":form:messages" />
<p:dataTable id="cars" var="car" value="#{articlesbean.LMatpilotaccess1}" editable="true" editMode="cell" widgetVar="carsTable" update=":cars">
<p:ajax event="cellEdit" oncomplete="onCellEdit()" />
...
</p:dataTable>
</p:outputPanel>
</h:form>
远程命令动作方法定义如下:
public void onCellEdit(CellEditEvent event) {
Object oldValue = event.getOldValue();
Object newValue = event.getNewValue();
if(newValue != null && !newValue.equals(oldValue)) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
但是,此方法从未被调用,并引发以下异常:
javax.el.MethodNotFoundException: Method not found: com.pfe.controller.ArticlesBean@1bb3a11.onCellEdit()
当我删除 CellEditEvent 参数时,它就起作用了。但我实际上需要旧值和新值。我该如何继续?
【问题讨论】:
标签: jsf jsf-2 primefaces celleditorlistener