CellEdit event not working after cell edit in primefaces

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

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

here is my code:

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()); }

回答1:

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"  />


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!