[ 2507390 ] FR - Save language and other login data in cookie

- better handling of language preference
This commit is contained in:
Heng Sin Low 2009-02-12 03:39:40 +00:00
parent 598b8a5f1f
commit 614873b5d4
4 changed files with 18 additions and 16 deletions

View File

@ -2,18 +2,13 @@
<classpath>
<classpathentry kind="src" path="WEB-INF/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="src" path="/base"/>
<classpathentry kind="lib" path="WEB-INF/lib/zk.jar" sourcepath="WEB-INF/lib/zk-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zcommon.jar" sourcepath="WEB-INF/lib/zcommon-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zul.jar" sourcepath="WEB-INF/lib/zul-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/junit.jar"/>
<classpathentry kind="src" path="/client"/>
<classpathentry kind="src" path="/JasperReports"/>
<classpathentry kind="src" path="/JasperReportsTools"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/C-_applications_apache-tomcat-5.5.26"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="lib" path="/tools/lib/xercesImpl.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zkmax.jar" sourcepath="WEB-INF/lib/zkmax-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zkex.jar" sourcepath="WEB-INF/lib/zkex-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/zkplus.jar" sourcepath="WEB-INF/lib/zkplus-sources.jar"/>
@ -22,9 +17,11 @@
<classpathentry kind="lib" path="WEB-INF/lib/zweb.jar" sourcepath="WEB-INF/lib/zweb-sources.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/jcommon.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/jfreechart.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/extend"/>
<classpathentry kind="lib" path="/tools/lib/javaee.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/cglib.jar"/>
<classpathentry kind="lib" path="WEB-INF/lib/fckez.jar"/>
<classpathentry kind="lib" path="/adempiere352a/tools/lib/j2ee.jar"/>
<classpathentry kind="lib" path="/adempiere352a/tools/lib/xercesImpl.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/ssp"/>
<classpathentry combineaccessrules="false" kind="src" path="/patches_352"/>
<classpathentry kind="output" path="WEB-INF/classes"/>
</classpath>

View File

@ -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
}
}
}

View File

@ -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");

View File

@ -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,