从iFrame关闭primefaces对话框

时间:2013-01-15 07:26:37

标签: jquery jsf jsf-2 primefaces

我有一个页面,我想在其中显示一个对话框。

代码:

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>

现在在这个对话框中我有iFrame,其中page2.xhtml被链接。

page2.xhtml

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

page2.xhtml包含一个commandButton。现在我在单击commandButton后关闭对话框。

不知道该怎么做。 我应该在page2.xhtml上的commandButton中写什么,以便关闭page1.xhtml上的对话框。请帮忙。

感谢。

2 个答案:

答案 0 :(得分:2)

尝试使用window.parent.dlgWVar.hide()。只有当主窗口和iframe都显示来自同一域的页面时,才能进行此操作。

答案 1 :(得分:0)

对我来说

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

工作。

相关问题