I am having an xhtml page called main page which contains another xhtml page called sub page, which wrapped inside of an iframe, so the structure somehow look like:
<!-- mainpage.xhtml -->
<div class="nav-head">
<ui:include src="header.xhtml" />
</div>
<div class="sub-page">
<iframe id="subpage" name="subpage" src="subpage.xhtml">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
In my subpage.xhtml, I have a select menu to change the locale of the application:
<h:selectOneMenu value="#{i18NController.language}" onchange="submit()">
<f:selectItems value="#{i18NController.availableLocales}" />
</h:selectOneMenu>
and in the controller I use : FacesContext.getCurrentInstance().getViewRoot().setLocale(currentLocale);
to set new locale for my application.
It worked fine, but my problem here is only the content of the subpage.xhtml changed while the other contents of the mainpage.xhtml did not change until I refreshed the whole mainpage.xhtml.
I know the problem is because in the controller I called FacesContext.getCurrentInstance().getViewRoot()
which return me the view of the subpage.xhtml (because I am calling it inside of the subpage.xhtml) and therefore only the view of the subpage is changed at this time. But I would like to ask if there is a possible way to get the view of my mainpage.xhtml also so that I can apply the new locale to this mainpage.xhtml at the same time with subpage.xhtml.