slub.team team mailing list archive
-
slub.team team
-
Mailing list archive
-
Message #00291
[Merge] lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production
Matthias Ronge has proposed merging lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production.
Requested reviews:
Saxon State Library Team (slub.team)
Related bugs:
Bug #1020522 in Goobi.Production: "improve behaviour of language switch"
https://bugs.launchpad.net/goobi-production/+bug/1020522
For more details, see:
https://code.launchpad.net/~zeutschel/goobi-production/bug-1020522/+merge/117015
Fixed forgetful language switch
--
https://code.launchpad.net/~zeutschel/goobi-production/bug-1020522/+merge/117015
Your team Saxon State Library Team is requested to review the proposed merge of lp:~zeutschel/goobi-production/bug-1020522 into lp:goobi-production.
=== modified file 'src/de/sub/goobi/forms/SpracheForm.java'
--- src/de/sub/goobi/forms/SpracheForm.java 2012-07-05 06:11:02 +0000
+++ src/de/sub/goobi/forms/SpracheForm.java 2012-07-27 07:44:40 +0000
@@ -29,6 +29,7 @@
import java.util.Locale;
import java.util.Map;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import de.sub.goobi.config.ConfigMain;
@@ -39,6 +40,8 @@
* user in the running application
*/
public class SpracheForm {
+
+ public static final String SESSION_LOCALE_FIELD_ID = "lang";
/**
* The constructor of this class loads the required MessageBundle
@@ -113,6 +116,7 @@
* This parameter can be either of form “‹language›” or of form
* “‹language›_‹country›”, e.g. “en” or “en_GB” are valid values.
*/
+ @SuppressWarnings("unchecked")
public void switchLanguage(String langCodeCombined) {
String[] languageCode = langCodeCombined.split("_");
Locale locale = null;
@@ -121,7 +125,9 @@
} else {
locale = new Locale(languageCode[0]);
}
- FacesContext.getCurrentInstance().getViewRoot().setLocale(locale);
+ FacesContext context = FacesContext.getCurrentInstance();
+ context.getViewRoot().setLocale(locale);
+ context.getExternalContext().getSessionMap().put(SESSION_LOCALE_FIELD_ID, locale);
}
/**
@@ -138,6 +144,17 @@
}
public Locale getLocale() {
- return FacesContext.getCurrentInstance().getViewRoot().getLocale();
+ FacesContext fac = FacesContext.getCurrentInstance();
+ @SuppressWarnings("rawtypes")
+ Map session = fac.getExternalContext().getSessionMap();
+ UIViewRoot frame = fac.getViewRoot();
+ if (session.containsKey(SESSION_LOCALE_FIELD_ID)) {
+ Locale locale = (Locale) session.get(SESSION_LOCALE_FIELD_ID);
+ if (frame.getLocale() != locale)
+ frame.setLocale(locale);
+ return locale;
+ } else {
+ return frame.getLocale();
+ }
}
}
Follow ups