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.
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