1

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.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Son
  • 67
  • 2
  • 14
  • Off-topic: 'onchange="submit()"` is very jsf1.x. On-topic: Wat to complex trying to solve that server side. If using ajax, you can more easily in the ''complete" event get to the parent document and reload that. But you could (if you are sure that result of the submit will always be ok) do a window reload or something of the parent. Way easier to solve things that way – Kukeltje Nov 02 '17 at 16:06
  • hi Kukeltje, thank you for your answer but I did not really get what you mean. Do you have here an example for that? Thank you! – Son Nov 03 '17 at 13:37

0 Answers0