I have tried MKyiong's and javacodegeeks's good guides - everything is working fine.
I have a template that contains navigation bar, contact info stored in WEB-INF/templates/default.xhtml. In this template I have a block containing
<div id="content">
<ui:insert name="content">
[Template content will be inserted here]
</ui:insert>
In my file WEB-INF/langTest.xhtml
I try
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
template="/WEB-INF/templates/default.xhtml">
<ui:define name="content"> <h:form>
<h2><h:outputText value="#{msg['welcome.jsf']}" /></h2>
<h:panelGrid columns="2">
Language :
<h:selectOneMenu value="#{language.localeCode}" onchange="submit()"
valueChangeListener="#{language.countryLocaleCodeChanged}">
<f:selectItems value="#{language.countriesInMap}" />
</h:selectOneMenu>
</h:panelGrid>
</h:form>
</ui:define>
</ui:composition>
When I run the project, visually everything is working, template is OK.
If I change my Firefox=>Preferences=>Content=>Languages settings everything is displayed in that language
BUT
If I want to change it by selecting other language from the dropdown menu
all the parts #{msg['welcome.jsf']}
does NOT change, they display the language that is defined in the browser properties.
I have put a this #{language.language}
in my WEB-INF/templates/default.xhtml
And it showing me that the Managed bean is accepting my language selection from the dropdown, but no effect on the #{msg['welcome.jsf']}
I think that I'm missing
<html lang="#{localeBean.language}"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"><f:view locale="#{localeBean.locale}">...</f:view></html>
Thanks.