Time for action – creating a confirmation dialog
Let us see how to create a confirmation dialog with Yes and No options.
Create a confirmation dialog using
<p:confirmDialog>
with two buttons for Yes and No options:<h:form id="form1" style="width: 300px; margin-left: 5px;"> <p:growl/> <p:panel header="User Form"> <h:panelGrid columns="2"> <h:outputText value="EmailId:" /> <p:inputText value="admin@gmail.com"/> <p:commandButton value="Delete" onclick="cnfDlg.show()" /> </h:panelGrid> </p:panel> <p:confirmDialog widgetVar="cnfDlg" header="Confirmation" message="Are you sure to delete?" > <p:commandButton value="Yes" actionListener="#{confirmDialogController.handleDelete}" oncomplete="cnfDlg.hide();" update="form1"/> <p:commandButton value="No" onclick="cnfDlg.hide();"/> </p:confirmDialog> </h:form>
Implement the action handler method using the following...