我有一个要显示对话框的页面。
代码:
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>
现在在此对话框中,我具有链接了page2.xhtml的iFrame。
page2.xhtml
<p:commandButton value ="Close Dialog">
</p:commandButton>
page2.xhtml包含一个commandButton。现在,我必须在单击命令按钮后关闭对话框。
不知道该怎么做。我应该在page2.xhtml上的commandButton中写些什么,以便关闭page1.xhtml上的对话框。请帮助。
谢谢。
对于较旧的PrimeFaces版本,请尝试使用window.parent.dlgWVar.hide()
。仅当主窗口和iframe都显示同一域中的页面时,才有可能。
对于PrimeFaces版本5及更高版本,请参见其他答案
对我来说
window.parent.PF('dlgWVar').hide()
工作。