Akshay Raut
Akshay Raut

Reputation: 565

Close primefaces dialog from iFrame

I've a page on which I want to show a dialog.

Code :

page1.xhtml

<p:commandLink value="Show Dialog" oncomplete="dlgWVar.show();"/>
<p:dialog widgetVar="dlgWVar"
          width="800"
          id="dialog"
          position="top"
          modal="true"
          header="Test Dialog"
          height="500">

    <iframe src="page2.xhtml" width="100%" height="500px" style="border-width: 0PX;">
    </iframe>

</p:dialog>

Now on this dialog I've iFrame in which the page2.xhtml is linked.

page2.xhtml

   <p:commandButton value ="Close Dialog">
   </p:commandButton>

page2.xhtml contains a commandButton. Now I've to close the dialog after clicking the commandButton.

Don't know how to do that. What should I write in commandButton on page2.xhtml so that the dialog on page1.xhtml will be closed. Please help.

Thanks.

Upvotes: 2

Views: 2585

Answers (2)

partlov
partlov

Reputation: 14277

For older PrimeFaces version try with window.parent.dlgWVar.hide(). This is only possible if both main window and iframe show the page from the same domain.

For PrimeFaces version of 5 and up, see the other answer

Upvotes: 3

user12263909
user12263909

Reputation: 1

For me

window.parent.PF('dlgWVar').hide()

worked.

Upvotes: 0

Related Questions