Author: liem_nguyen
Date: 2009-11-13 03:36:41 -0500 (Fri, 13 Nov 2009)
New Revision: 591
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java
Log:
GTNPORTAL-182 Always keep old language when change langauge in New Account portlet
Modified:
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java
===================================================================
---
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java 2009-11-13
08:34:02 UTC (rev 590)
+++
portal/trunk/webui/eXo/src/main/java/org/exoplatform/webui/organization/UIUserProfileInputSet.java 2009-11-13
08:36:41 UTC (rev 591)
@@ -104,34 +104,64 @@
}
else if (key.equalsIgnoreCase("user.language"))
{
- List<SelectItemOption<String>> lang = new
ArrayList<SelectItemOption<String>>();
- LocaleConfigService localeService =
getApplicationComponent(LocaleConfigService.class);
- Locale currentLocale =
((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getLocale();
- Iterator i = localeService.getLocalConfigs().iterator();
- String displayLanguage = null;
- String displayName = null;
- String language = null;
- while (i.hasNext())
- {
- LocaleConfig config = (LocaleConfig)i.next();
- displayLanguage = config.getLocale().getDisplayLanguage(currentLocale);
- displayName = config.getLocale().getDisplayName(currentLocale);
- language = config.getLanguage();
- if (config.getLanguage().equals("en"))
- {
- lang.add(0, new SelectItemOption<String>(displayLanguage,
language, displayName));
- continue;
- }
- lang.add(new SelectItemOption<String>(displayLanguage, language,
displayName));
- }
- UIFormSelectBox langSelectBox = new UIFormSelectBox(key, key, lang);
+ UIFormSelectBox langSelectBox = new UIFormSelectBox(key, key, null);
set.addUIFormInput(langSelectBox);
+ initLanguageCombo();
continue;
}
set.addUIFormInput(new UIFormStringInput(key, null, null));
}
}
+ /**
+ * Update language select box
+ */
+ @Override
+ public void processRender(WebuiRequestContext context) throws Exception
+ {
+ initLanguageCombo();
+ super.processRender(context);
+ }
+
+ private void initLanguageCombo()
+ {
+ UIFormSelectBox langSelectBox = this.findComponentById("user.language");
+ if (langSelectBox == null)
+ return;
+ String selectedLang = langSelectBox.getSelectedValues()[0];
+
+ List<SelectItemOption<String>> lang = new
ArrayList<SelectItemOption<String>>();
+ langSelectBox.setOptions(lang); // Clear
+
+ LocaleConfigService localeService =
getApplicationComponent(LocaleConfigService.class);
+ Locale currentLocale =
((PortletRequestContext)WebuiRequestContext.getCurrentInstance()).getLocale();
+ Iterator<LocaleConfig> i = localeService.getLocalConfigs().iterator();
+ String displayLanguage = null;
+ String displayName = null;
+ String language = null;
+ SelectItemOption<String> option;
+ while (i.hasNext())
+ {
+ LocaleConfig config = i.next();
+ displayLanguage = config.getLocale().getDisplayLanguage(currentLocale);
+ displayName = config.getLocale().getDisplayName(currentLocale);
+ language = config.getLanguage();
+ option = new SelectItemOption<String>(displayLanguage, language,
displayName);
+ if (lang.equals(selectedLang))
+ {
+ option.setSelected(true);
+ }
+ if (config.getLanguage().equals("en"))
+ {
+ lang.add(0, option);
+ continue;
+ }
+ lang.add(option);
+ }
+
+ langSelectBox.setOptions(lang);
+ }
+
@SuppressWarnings("deprecation")
public void setUserProfile(String user) throws Exception
{
Show replies by date