从内部iframe刷新父级中的组件 [英] Refresh component in parent from inner iframe
本文介绍了从内部iframe刷新父级中的组件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个xhtml(primefaces)简单页面:
I have this xhtml (primefaces) simple page:
....
<div id="header">
<h:outputText value="#{userBean.name}"/>
</div>
<div id="content">
<p:tabView value="#{appTabbedView.tabs}" var="tab" dynamic="true"
cache="false">
<p:tab title="#{tab.title}">
<iframe frameborder="0" src="#{tab.page}" />
</p:tab>
</p:tabView>
</div>
.....
在iframe内,我加载了一个p:tab,该页面加载了一个名为"Profile.xhtml"的页面,该页面允许编辑(更改)用户名. 如何刷新标题以显示新用户的名称(在iframe中!)? 我找不到解决方案,我尝试了一切.
Inside the iframe, I load a p:tab which loads a page named "Profile.xhtml" which allows edit (change) the user's name. How can I refresh the header to show the new user's name (im inside an iframe!)? I cant find a solution, I tried everything.
推荐答案
这是我的解决方案.可行!
This is my solution. It works!
....
<div id="header">
<h:form id="formHeader">
<p:commandLink id="hiddenLink" update="user" value="hiddenLink" style="display:none" />
<h:outputText value="#{userBean.name}" id="user"/>
</h:form>
</div>
<div id="content">
<p:tabView value="#{appTabbedView.tabs}" var="tab" dynamic="true" cache="false">
<p:tab title="#{tab.title}">
<iframe frameborder="0" src="#{tab.page}" />
</p:tab>
</p:tabView>
</div>
.....
script.js:
script.js:
function refreshHeader() {
window.parent.document.getElementById('formHeader:hiddenLink').click();
}
在Profile.xhtml内部:
inside Profile.xhtml:
....
<p:commandButton id="accept" ... oncomplete="refreshHeader()" />
....
这篇关于从内部iframe刷新父级中的组件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文