Close a lightBox primefaces from iframe Button

╄→гoц情女王★ 提交于 2019-12-08 09:56:40

问题


I use primefaces lightbox component with seam. I have a firstpage.xhtml page, where I have a button that display a lightbox with iframe parameter, that will display a secondpage.xhtml that have some form fields and a "Close Window" button.

Code of firstpage.xhtml

>  <ui:composition xmlns="http://www.w3.org/1999/xhtml"
>   xmlns:ui="http://java.sun.com/jsf/facelets"
>   xmlns:h="http://java.sun.com/jsf/html"
>   xmlns:f="http://java.sun.com/jsf/core"
>   xmlns:p="http://primefaces.prime.com.tr/ui"
>   xmlns:opt="http://primefaces.prime.com.tr/optimus"
>   template="layout/template1.xhtml"> <ui:define name="head">
> <p:resources/> </ui:define>
>               <ui:define name="body">
>   
>           <h1 class="title">LightBox - External URL</h1>      <div class="entry">
>               <p>LightBox can display external urls in an iframe.</p>
>                   
>                   <p:lightBox id="light" iframe="true" width="80%" height="80%" widgetVar="dlg">
>                   
>                         <h:outputLink value="#{request.contextPath}/PermissionEdit.seam" title="PrimeFaces
> HomePage">
>                           <h:outputText value="PrimeFaces HomePage"/>
>                       </h:outputLink>
>                   </p:lightBox>
> 
>               <h3>Source</h3> <pre name="code" class="xml"> &lt;p:lightBox iframe="true" width="80%" height="80%"&gt;     &lt;h:outputLink
> value="http://primefaces.org" title="PrimeFaces HomePage"&gt; 
>       &lt;h:outputText value="PrimeFaces HomePage"/&gt; 
>   &lt;/h:outputLink&gt;  &lt;/p:lightBox&gt; </pre>
> 
> </div> </ui:define> </ui:composition>

Could please someone tell me how to implement a close method to close this lightbox iframe window when i click on the close button on the secondpage.xhtml?

Thanks in advance


回答1:


Reloading a page could be very expensive:

onclick="javascript:window.parent.location.reload(true);"

You can use slightly different approach:

<p:lightBox id="light" iframe="true" width="80%" height="80%" widgetVar="dlg">

on iframe side:

<p:commandButton value="Close" onsuccess="parent.dlg.hide();" ajax="true" process="@none" />


来源:https://stackoverflow.com/questions/7874254/close-a-lightbox-primefaces-from-iframe-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!