CellEdit event not working after cell edit in prim

2019-05-02 11:14发布

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条回答
放我归山
2楼-- · 2019-05-02 12:11

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" 
/>
查看更多
登录 后发表回答