我使用Primefaces 3.5.jar和Hibernate。 我有數據錶行編輯監聽器的問題。當我調試項目我可以進入onCancel方法,但onEdit永遠不會啓動。我的XHTML代碼:Primefaces行編輯監聽器不會工作
<f:facet name="header">
Workhours
</f:facet>
<p:ajax event="rowEdit" listener="#{workhoursBean.onEdit}" update=":form:messages" />
<p:ajax event="rowEditCancel" listener="#{workhoursBean.onCancel}" update=":form:messages" />
<p:column headerText="Start" style="width:20%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{workhours.workStart}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{workhours.workStart}" style="width:100%" label="Year"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="End" style="width:20%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{workhours.workEnd}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{workhours.workEnd}" style="width:100%" label="Year"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column style="width:6%">
<p:rowEditor />
</p:column>
</p:dataTable>
而且我Bean方法:
public void onCancel(RowEditEvent event) {
//do stuff
}
public void onEdit(RowEditEvent event) {
Object oldValue = event.getObject();
Object newValue = event.getObject();
if(newValue != null && !newValue.equals(oldValue)) {
FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
FacesContext.getCurrentInstance().addMessage(null, msg);
}
}
有任何想法,爲什麼?