本文介绍了在Primefaces中进行单元格编辑后,CellEdit事件不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在Primefaces中按单元格创建一个可编辑的数据表,但是在对单元格进行编辑后,未提交事件,我的代码无法检测到newValue,并且没有错误或在堆栈跟踪中记录了日志
I am trying to make an Editable DataTable by cell in Primefaces, but after an edit of a cell, the event not submitted and my code can't detect the newValue, and there is no error or log in the stack trace
这是我的代码:
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>
Bean:
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方法
try to add the attribute immediate="true"
in the in the tag p:ajax and my bean method was called
<p:ajax event="cellEdit"
update="ListC"
immediate="true"
listener="#{recruitmentProcessMB.onCellEdit}"
process="@this"
/>
这篇关于在Primefaces中进行单元格编辑后,CellEdit事件不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!