SelectOneMenu does not trigger valueChangeListener  XML
Forum Index -> General Help
Author Message

Joined: 07/Jun/2011 08:31:43
Messages: 30

Hi there,

Just a small question, which I assume anyone would be able to answer in just 5 seconds... but I cannot figure out where my code is wrong. Here is my code :

 		<ice:selectOneMenu valueChangeListener="#{UserSessionParameters.changeLanguage}" value="#{UserSessionParameters.userLanguage.language}">
 			<f:selectItem itemValue="de" itemLabel="#{msgs.german}" />
 			<f:selectItem itemValue="fr" itemLabel="#{msgs.french}" />

And bean :

public class UserSessionParameters implements Serializable {
   private static final long serialVersionUID = 777202849618067315L;
   private Locale userLanguage;
   public UserSessionParameters(){
   public void initialize(){
     this.userLanguage = FacesContext.getCurrentInstance().getViewRoot().getLocale();
     System.out.println("User language initialized : " + userLanguage.getLanguage());
   public Locale getUserLanguage() {
     return userLanguage;
   public void setUserLanguage(Locale userLanguage) {
     this.userLanguage = userLanguage;
   public void changeLanguage(ValueChangeEvent event){
     System.out.println("Calling changeValueListener in UserSessionParameters managed bean");
     String newLocale = (String)event.getNewValue();
     if(newLocale.equals("fr")) FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.FRENCH);
     else FacesContext.getCurrentInstance().getViewRoot().setLocale(Locale.GERMAN);
     this.userLanguage = JSFHelper.getLocale();

The HTML select menu do correctly appears, and it has correctly the "french" item selected. However, the listener for the value change is never called. My System.out in changeLanguage never appeared in the console.

Thanks in advance for any help or suggestion.

Joined: 02/Jan/2007 00:00:00
Messages: 426


Does setting partialSubmit=true on the selectOneMenu component help?


Arran McCullough
Technical Support Engineer
ICEsoft Technologies Inc.

Joined: 07/Jun/2011 08:31:43
Messages: 30

Hi Arran and thank you for the answer.

It does work with the partialSubmit=true option.

I do not fully understand the reason of this requirement. Other listeners (for instance actionListeners on commandlinks) do not require having the partial submit option activated.

Anyway, it's working perfectly now.
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team