Calling method when closing dialog

Asked

Viewed 874 times

0

This code is the showcase of the primefaces :

<h:panelGrid columns="1" cellpadding="5">
    <p:commandButton value="Basic" type="button" onclick="PF('dlg1').show();" />

    <p:commandButton value="Modal" type="button" onclick="PF('dlg2').show();" />

    <p:commandButton value="Effects" type="button" onclick="PF('dlg3').show();" /> 
</h:panelGrid>

<p:dialog header="Basic Dialog" widgetVar="dlg1" minHeight="40">
    <h:outputText value="Resistance to PrimeFaces is futile!" />
</p:dialog>

<p:dialog header="Modal Dialog" widgetVar="dlg2" modal="true" height="100">
    <h:outputText value="This is a Modal Dialog." />
</p:dialog>   

<p:dialog header="Effects" widgetVar="dlg3" showEffect="explode" hideEffect="bounce" height="100">
    <h:outputText value="This dialog has nice effects." />
</p:dialog>

I put it on to help with the understanding. I would like to know how I can invoke a method if I close the dialog by 'x' in the upper right corner as it is in the image.

inserir a descrição da imagem aqui

1 answer

1


In the Primefaces Dialog documentation (primefaces_user_guide.pdf) have an example:

<p:dialog>
  <p:ajax event="close" listener="#{dialogBean.handleClose}" update="msg" />
  //Content
</p:dialog>

<p:messages id="msg" />

.

public class DialogBean {
  public void handleClose(CloseEvent event) {
    //Add facesmessage
  }
}
  • Show, thank you very much.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.