I'm facing strange behavior of the localization. I've two languages in my app - english and slovak. On my local Glassfish switching locale works perfectly. But the same application deployed on Jelastic Glassfish is always in english. Switching locale doesn't work. I've debugged the remote app and facescontext (FacesContext.getCurrentInstance().getViewRoot().getLocale() and FacesContext.getCurrentInstance().getExternalContext().getRequestLocale()) returns correct sk locale, but the page is still in english. In language menu is slovak (2nd option) selected!
Both Glassfishes are in version 3.1.2.2 with Mojarra 2.2.7 and Primefaces 5.0, running on JDK7. Local GF runs on Win7, remote on Linux (CentOS?) and it's clustered (maybe this is the reason?)
faces-conf.xml
<locale-config>
<default-locale>en</default-locale>
<supported-locale>sk</supported-locale>
</locale-config>
<resource-bundle>
<base-name>Bundle</base-name>
<var>bundle</var>
</resource-bundle>
login.xhtml
<f:view locale="#{loginBean.locale}">
...
<p:outputLabel value="#{bundle.language}: "/>
<p:selectOneMenu value="#{loginBean.language}" id="loginLocale">
<f:selectItem itemValue="en" itemLabel="English" />
<f:selectItem itemValue="sk" itemLabel="Slovensky" />
<p:ajax update="@all"/>
</p:selectOneMenu>
...
</f:view>
LoginBean.java
@ManagedBean(name = "loginBean")
@SessionScoped
public class LoginBean implements Serializable{
private Locale locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale();
...
public Locale getLocale() {
return locale;
}
public String getLanguage() {
return locale.getLanguage();
}
public void setLanguage(String language) {
locale = new Locale(language);
FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
}
}
Thank you for any help
Michal