To be able to do this

  | <h:selectOneMenu value="#{localeSelector.localeString}">
  |     <f:selectItems value="#{localeSelector.supportedLocales}" />
  | </h:selectOneMenu>
  | <h:commandButton action="#{localeSelector.select}" 
value="#{messages['button.changeLocale']}"/> 
  | 

I added this to LocaleSelector, and it looks like it's working as it should. 
The only flaw is that the list is not sorted and perhaps all language names 
should begin with an uppercase letter to be consistent within the list. My list 
(based on supported locales "sv" and "en") now says "svenska, English" since 
Swedish spelling rules says it should be written with a lowercase "s").


  |     private ArrayList<SelectItem> supportedLocales;
  | 
  |     public String getLocaleString()
  |     {
  |         return getLocale().toString();
  |     }
  | 
  |     public void setLocaleString(String localeString)
  |     {
  |         String[] localeParts = localeString.split("_");
  |         if (localeParts.length > 0)
  |         {
  |             this.language = localeParts[0];
  |         }
  |         if (localeParts.length > 1)
  |         {
  |             this.country = localeParts[1];
  |         }
  |         if (localeParts.length > 2)
  |         {
  |             this.variant = localeParts[2];
  |         }
  |     }
  | 
  |     @Create
  |     public void setSupportedLocales()
  |     {
  |         this.supportedLocales = new ArrayList<SelectItem>();
  |         Locale supportedLocale;
  |         SelectItem selectItem;
  |         FacesContext facesContext = FacesContext.getCurrentInstance();
  |         for (Iterator it = 
facesContext.getApplication().getSupportedLocales(); it.hasNext();)
  |         {
  |             supportedLocale = (Locale) it.next();
  |             selectItem = new SelectItem(supportedLocale.toString(), 
supportedLocale.getDisplayLanguage(supportedLocale));
  |             this.supportedLocales.add(selectItem);
  |         }
  |     }
  | 
  |     public ArrayList<SelectItem> getSupportedLocales()
  |     {
  |         return this.supportedLocales;
  |     }
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3929646#3929646

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3929646


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to