Time for action – the Dialog component close event listener
Let us see how we can register a listener for the close
event using the following steps:
Create a Dialog component and register a
close
event listener using the<p:ajax>
tag:<h:form id="form3" style="width: 400px;"> <p:messages id="msgs" for="SampleDialog"/> <p:panel header="Dialog - Close Event Listener"> <p:commandButton value="ShowDialog" onclick="dlg3.show();" type="button" /> <p:dialog id="SampleDialog" header="Sample Dialog" widgetVar="dlg3" width="300" height="50" showEffect="bounce" hideEffect="explode" closeOnEscape="true"> <p:ajax event="close" update="msgs" listener="#{dialogController.handleDialogClose}"/> <p:outputLabel value="PrimeFaces Dialog"/> </p:dialog> </p:panel> </h:form>
Implement the
handleDialogClose()
method to handle the close event:public void handleDialogClose(CloseEvent event) { String...