title: Language switcher implementation in JSF
body: <p>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 <code>SelectOneMenu</code> for switching the language:</p>
  
  <pre><code>&lt;h:form&gt;
      &lt;p:panelGrid columns="2" &gt;
          &lt;h:outputText value="#{msgs.SelectLanguage}" /&gt;
          &lt;p:selectOneMenu value="#{languageSwitcher.selectedLanguage}" &gt;
              &lt;f:selectItems value="#{languageSwitcher.languages}" &gt;&lt;/f:selectItems&gt;
          &lt;/p:selectOneMenu&gt; 
      &lt;/p:panelGrid&gt;
  &lt;/h:form&gt;
  </code></pre>
  
  <p>The switcher works well.
  My problem is how to reload the translated messages when a language is selected.</p>
  
  <p>I have tried these options:</p>
  
  <p><strong>Option 1</strong></p>
  
  <p>With an ajax update inside the selectOneMenu:</p>
  
  <pre><code>&lt;p:ajax update="myFormsTobeUpdated" &gt;&lt;/p:ajax&gt;
  </code></pre>
  
  <p>This works great, and is the preferred solution because it's Ajax, but </p>
  
  <p>EDITED</p>
  
  <p>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.</p>
  
  <p><strong>Option 2</strong></p>
  
  <p>With a complete reload of the page in Javascript. I have tried this but doesn't work (can't tell why):</p>
  
  <pre><code>&lt;p:selectOneMenu value="#{languageSwitcher.selectedLanguage}" onchange="window.location.reload()" &gt;
  </code></pre>
  
  <p><strong>Option 3</strong></p>
  
  <p>With a complete reload of the page in Java like explained here: <a href="https://stackoverflow.com/a/1821708/870122">https://stackoverflow.com/a/1821708/870122</a> (to be honest I haven't tried it yet, but will do soon!)</p>
  
  <p>Any suggestions are welcome.</p>