I have an iFrame in my page looking like this:
<h:panelGroup id="gameDiv">
<f:verbatim>
<iframe src="/levelup/resources/#{cc.attrs.src_dir}/#{cc.attrs.src_html}" width="700px" height="800px" frameborder="0" id="gameFrame">
</iframe>
</f:verbatim>
</h:panelGroup>
Basically, the "src" variable is bound using JSF 2.0 EL, and gets its value from a backing bean.
I then开发者_开发百科 use a form to update this value, and refresh the whole page. In the rendered HTML, I can see that the "src" for my div has been updated. However, the HTML page still shows the old one.
I thought the issue was similar to 2 iframes with the same display even if the src are different, and I tried the solutions that have been mentioned (using a timestamp to make the src unique, or resetting them to "about:blank" on each page load). None of them worked however.
For information, the form that updates the backing bean is:
<h:form id="gameSelectionForm">
<h:selectOneMenu id="gameSelection">
<f:selectItems value="#{gameBean.gameIds}" />
</h:selectOneMenu>
<p:commandButton id="gameSelector" action="#{gameBean.changeGame}" update="gameScoreFieldset, gameDiv" />
</h:form>
Any hint would be much useful.
Thanks in advance,
SébastienYou're changing the src
of the iframe
using JS/Ajax, but not reloading its content.
There are 2 ways to fix this:
Just don't use JS/ajax. A synchronous HTTP request will reload the entire document and thus automagically reload the
iframe
.<p:commandButton ajax="false" />
Use JS to force reload. Add the following after the
<iframe>
.<script>document.getElementById('gameFrame').location.reload()</script>
Oh, you definitely need to remove the <f:verbatim>
. Since JSF 1.2 that tag is utterly useless.
精彩评论