From 614873b5d4840e5f5590a858fbc399db3b09e585 Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Thu, 12 Feb 2009 03:39:40 +0000 Subject: [PATCH] [ 2507390 ] FR - Save language and other login data in cookie - better handling of language preference --- zkwebui/.classpath | 11 ++++------- .../org/adempiere/webui/panel/LoginPanel.java | 18 ++++++++++-------- .../org/adempiere/webui/panel/RolePanel.java | 2 +- .../adempiere/webui/util/UserPreference.java | 3 +++ 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/zkwebui/.classpath b/zkwebui/.classpath index 3aaece075d..0fc93956b2 100644 --- a/zkwebui/.classpath +++ b/zkwebui/.classpath @@ -2,18 +2,13 @@ - - - - - @@ -22,9 +17,11 @@ - - + + + + diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java index 60be2cbd56..081122035a 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/LoginPanel.java @@ -181,10 +181,10 @@ public class LoginPanel extends Window implements EventListener if (event.getName().equals(Events.ON_SELECT)) { if(eventComp.getId().equals(lstLanguage.getId())) { - String langName = (String) lstLanguage.getSelectedItem().getValue(); - Env.setContext(ctx, Env.LANGUAGE, langName); - Language language = Language.getLanguage(langName); + String langName = (String) lstLanguage.getSelectedItem().getLabel(); + Language language = Language.getLanguage(langName); Env.verifyLanguage(ctx, language); + Env.setContext(ctx, Env.LANGUAGE, language.getAD_Language()); res = ResourceBundle.getBundle(RESOURCE, language.getLocale()); lblUserId.setValue(res.getString("User")); @@ -210,7 +210,10 @@ public class LoginPanel extends Window implements EventListener { Listitem li = lstLanguage.getItemAtIndex(i); if(li.getLabel().equals(initDefault)) - lstLanguage.setSelectedItem(li); + { + lstLanguage.setSelectedIndex(i); + break; + } } } } @@ -235,15 +238,14 @@ public class LoginPanel extends Window implements EventListener { String langName = null; if ( lstLanguage.getSelectedItem() != null ) - langName = (String) lstLanguage.getSelectedItem().getValue(); + langName = (String) lstLanguage.getSelectedItem().getLabel(); else langName = Language.getBaseLanguage().getName(); - Env.setContext(ctx, Env.LANGUAGE, langName); - Language language = Language.getLanguage(langName); + Language language = Language.getLanguage(langName); Env.verifyLanguage(ctx, language); wndLogin.loginOk(userId, userPassword); - Env.setContext(ctx, "Language", lstLanguage.getSelectedItem().getLabel()); // Elaine 2009/02/06 + Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06 } } } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java index 42f043cfa4..a091713b79 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/panel/RolePanel.java @@ -378,7 +378,7 @@ public class RolePanel extends Window implements EventListener // Elaine 2009/02/06 save preference to AD_Preference UserPreference userPreference = SessionManager.getSessionApplication().getUserPreference(); - userPreference.setProperty(UserPreference.P_LANGUAGE, Env.getContext(Env.getCtx(), "Language")); + userPreference.setProperty(UserPreference.P_LANGUAGE, Env.getContext(Env.getCtx(), UserPreference.LANGUAGE_NAME)); userPreference.setProperty(UserPreference.P_ROLE, lstItemRole != null ? (String) lstItemRole.getValue() : "0"); userPreference.setProperty(UserPreference.P_CLIENT, lstItemClient != null ? (String) lstItemClient.getValue() : "0"); userPreference.setProperty(UserPreference.P_ORG, lstItemOrg != null ? (String) lstItemOrg.getValue() : "0"); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/util/UserPreference.java b/zkwebui/WEB-INF/src/org/adempiere/webui/util/UserPreference.java index fe4fe61e57..d367422491 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/util/UserPreference.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/util/UserPreference.java @@ -48,6 +48,9 @@ public final class UserPreference implements Serializable { public static final String P_WAREHOUSE = "Warehouse"; private static final String DEFAULT_WAREHOUSE = ""; + /** Language Name Context **/ + public static final String LANGUAGE_NAME = "#LanguageName"; + /** Ini Properties */ private static final String[] PROPERTIES = new String[] { P_LANGUAGE,