I have a complex jsf page with some widgets developed in PrimeFaces. Up to now, the application is completely ajaxified, meaning that there aren't submits, but all the events and updates are handled through Ajax behavior (this is not a must, but a nice-to-have feature). I have also done a SelectOneMenu
for switching the language:
<h:form>
<p:panelGrid columns="2" >
<h:outputText value="#{msgs.SelectLanguage}" />
<p:selectOneMenu value="#{languageSwitcher.selectedLanguage}" >
<f:selectItems value="#{languageSwitcher.languages}" ></f:selectItems>
</p:selectOneMenu>
</p:panelGrid>
</h:form>
The switcher works well. My problem is how to reload the translated messages when a language is selected.
I have tried these options:
Option 1
With an ajax update inside the selectOneMenu:
<p:ajax update="myFormsTobeUpdated" ></p:ajax>
This works great, and is the preferred solution because it's Ajax, but
EDITED
this solution doesn't ajax-update the Tab titles in the PrimeFaces TabView, and this is problem is blocking because the Tab titles need to be translated.
Option 2
With a complete reload of the page in Javascript. I have tried this but doesn't work (can't tell why):
<p:selectOneMenu value="#{languageSwitcher.selectedLanguage}" onchange="window.location.reload()" >
Option 3
With a complete reload of the page in Java like explained here: https://stackoverflow.com/a/1821708/870122 (to be honest I haven't tried it yet, but will do soon!)
Any suggestions are welcome.