在 primefaces 中编辑单元格后,CellEdit 事件不起作用
CellEdit event not working after cell edit in primefaces
我正在尝试在 Primefaces 中按单元格制作一个可编辑数据表,但在编辑单元格后,事件未提交并且我的代码无法检测到新值,并且堆栈中没有错误或日志踪迹
这是我的代码:
xhtml:
<p:dataTable id="ListC"
value="#{recruitmentProcessMB.candidateListInProcess}"
var="candid" rowKey="#{candid.idCandidate}"
style="border:0px; " editable="true" editMode="cell">
<p:ajax event="cellEdit"
update="ListC"
listener="#{recruitmentProcessMB.onCellEdit}"
/>
<p:column headerText="Date d'entretien">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{candid.interviewDateCandidate}">
<f:convertDateTime type="date" dateStyle="short"
pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar id="date"
value="#{candid.interviewDateCandidate}"
navigator="true" pattern="dd/MM/yyyy" mask="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column id="vRH" headerText="Validation Par RH " disabledSelection="#{candid.currentTask!='InterviewAndValidationByRH'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText
value="#{candid.decisionOfRh}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu id="rhDecision" style="display: inline-block;"
value="#{candid.decisionOfRh}"
disabled="#{candid.currentTask!='InterviewAndValidationByRH'}" >
<f:selectItem itemLabel="Selectionner..." />
<f:selectItem itemLabel="Accepté" itemValue="Accepté"/>
<f:selectItem itemLabel="Refusé" itemValue="Refusé"/>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
豆子:
public void onCellEdit(CellEditEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
Candidate c = context.getApplication().evaluateExpressionGet(
context, "#{candid}", Candidate.class);
System.out.println("+++++++++++ "+c.getFirstNameCandidate()+" "+c.getNameCandidate());
System.out.println("*********** "+event.getNewValue().toString());
logger.info(c.getInterviewDateCandidate().toString());
}
尝试在标记 p:ajax 中添加属性 immediate="true"
并且调用了我的 bean 方法
<p:ajax event="cellEdit"
update="ListC"
immediate="true"
listener="#{recruitmentProcessMB.onCellEdit}"
process="@this"
/>
我正在尝试在 Primefaces 中按单元格制作一个可编辑数据表,但在编辑单元格后,事件未提交并且我的代码无法检测到新值,并且堆栈中没有错误或日志踪迹
这是我的代码:
xhtml:
<p:dataTable id="ListC"
value="#{recruitmentProcessMB.candidateListInProcess}"
var="candid" rowKey="#{candid.idCandidate}"
style="border:0px; " editable="true" editMode="cell">
<p:ajax event="cellEdit"
update="ListC"
listener="#{recruitmentProcessMB.onCellEdit}"
/>
<p:column headerText="Date d'entretien">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{candid.interviewDateCandidate}">
<f:convertDateTime type="date" dateStyle="short"
pattern="dd/MM/yyyy" timeZone="Europe/Paris" />
</h:outputText>
</f:facet>
<f:facet name="input">
<p:calendar id="date"
value="#{candid.interviewDateCandidate}"
navigator="true" pattern="dd/MM/yyyy" mask="true" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column id="vRH" headerText="Validation Par RH " disabledSelection="#{candid.currentTask!='InterviewAndValidationByRH'}">
<p:cellEditor >
<f:facet name="output">
<h:outputText
value="#{candid.decisionOfRh}" />
</f:facet>
<f:facet name="input">
<h:selectOneMenu id="rhDecision" style="display: inline-block;"
value="#{candid.decisionOfRh}"
disabled="#{candid.currentTask!='InterviewAndValidationByRH'}" >
<f:selectItem itemLabel="Selectionner..." />
<f:selectItem itemLabel="Accepté" itemValue="Accepté"/>
<f:selectItem itemLabel="Refusé" itemValue="Refusé"/>
</h:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
豆子:
public void onCellEdit(CellEditEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
Candidate c = context.getApplication().evaluateExpressionGet(
context, "#{candid}", Candidate.class);
System.out.println("+++++++++++ "+c.getFirstNameCandidate()+" "+c.getNameCandidate());
System.out.println("*********** "+event.getNewValue().toString());
logger.info(c.getInterviewDateCandidate().toString());
}
尝试在标记 p:ajax 中添加属性 immediate="true"
并且调用了我的 bean 方法
<p:ajax event="cellEdit"
update="ListC"
immediate="true"
listener="#{recruitmentProcessMB.onCellEdit}"
process="@this"
/>