2011-10-24 104 views
0

我使用带接缝的primefaces lightbox组件。 我有一个firstpage.xhtml页面,其中有一个显示带有iframe参数的lightbox的按钮,它将显示带有一些表单字段和“关闭窗口”按钮的secondpage.xhtml。从iframe关闭lightBox primefaces按钮

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

代码可以请人告诉我如何实现一个close方法来关闭这个灯箱iframe的窗口时,我就在secondpage.xhtml的关闭按钮点击?

在此先感谢

+2

我用onclick =“解决了这个问题的javascript:window.parent.location.reload(真)“; –

+0

看看[这里] [1]的回答帮助你解决问题 [1]:http://stackoverflow.com/questions/13048637/primefaces-lightbox-closes-at-click-on-commandlink – MStack

回答

3

重新加载页面可能是非常昂贵的:

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

您可以使用稍微不同的方法:

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

上的iframe方:

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