【问题标题】:Close primefaces dialog from iFrame从 iFrame 关闭 primefaces 对话框
【发布时间】:2012-12-29 06:25:25
【问题描述】:

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

代码:

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 包含一个命令按钮。现在我必须在单击命令按钮后关闭对话框。

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

谢谢。

【问题讨论】:

  • 这是非常糟糕的设计。您应该通过 Facelets 而不是 HTML iframe 使用服务器端包含/模板。
  • 感谢 BalusC 的建议。我要改进我的设计。

标签: jquery jsf jsf-2 primefaces


【解决方案1】:

对于较旧的 PrimeFaces 版本,请尝试使用 window.parent.dlgWVar.hide()。这只有在主窗口和 iframe 都显示来自同一域的页面时才有可能。

对于 PrimeFaces 5 及以上版本,请参阅其他答案

【讨论】:

    【解决方案2】:

    对我来说

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

    工作。

    【讨论】:

      猜你喜欢
      • 2016-05-12
      • 2017-06-04
      • 2011-05-22
      • 2012-09-20
      • 1970-01-01
      • 1970-01-01
      • 2011-04-04
      • 2014-12-04
      • 1970-01-01
      相关资源
      最近更新 更多