jsf-2primefacesconfirmroweditor

Show a confirm message before <p:rowEditor> updates the model on click of "OK" button


I'm using <p:rowEditor> as follows:

<p:column headerText="Libellé">
    <p:cellEditor>
        <f:facet name="output">
            <h:outputText value="#{lot.libelle}" />
        </f:facet>
        <f:facet name="input">
            <p:inputText value="#{lot.libelle}" />
        </f:facet>
    </p:cellEditor>
</p:column>

<p:column>
    <p:rowEditor />
</p:column>

I would like to show a confirm message before the <p:rowEditor> updates the model on click of the "OK" button. How can I achieve this?


Solution

  • You can use onstart attribute of <p:ajax event="rowEdit"> for this.

    <p:dataTable ...>
        <p:ajax event="rowEdit" onstart="return confirm('Are you sure?')" />
        ...
    </p:dataTable>