I wounder the value change listener event is not fired. Also, I tried f:valueChangeListener
and never get the event fired.
I'm using primefaces 5.3
Any Help, Please.
-- Here is the form
<h:form id = "templatelocal_id" name="templatelocal_form">
<ul>
<li>
<h:selectOneMenu
id="locale_menu_id"
value="#{localizationBean.selectedLocalName}"
valueChangeListener="#{localizationBean.changeLanguage}"
onchange="submit()">
<f:selectItems
var="c"
value="#{localizationBean.localsList}"
itemLabel="#{c.displayLanguage}"
itemValue="#{c.displayLanguage}" />
</h:selectOneMenu>
</li>
</ul>
</h:form>
Here is the backing bean.
List item
@ManagedBean(name="localizationBean") @SessionScoped public class LocalizationBean { private Locale locale; private Locale selectedLocalName; private List<Locale> localsList = new ArrayList<Locale>(); public LocalizationBean() { System.out.println("--------"); } @PostConstruct public void init() { System.out.println("--------Init"); locale = FacesContext.getCurrentInstance().getExternalContext().getRequestLocale(); localsList.add(locale); Iterator<Locale> lsList = FacesContext.getCurrentInstance().getApplication().getSupportedLocales(); while (lsList.hasNext()) { Locale currentLocale = lsList.next(); localsList.add(currentLocale); } } public void changeLanguage(ValueChangeEvent e) { System.out.println("--------change"); Object newValue = e.getNewValue(); System.out.println("-----------" + newValue); } 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); } public Locale getSelectedLocalName() { return selectedLocalName; } public void setSelectedLocalName(Locale selectedLocalName) { this.selectedLocalName = selectedLocalName; } public List<Locale> getLocalsList() { return localsList; } public void setLocalsList(List<Locale> localsList) { this.localsList = localsList; } }