Fixed NPE in tests due to changes in I18nHelper.
* setPreferredLocale extracted to a new method * Checked if Executions.getCurrent() is null FEA: ItEr75S04BugFixing
This commit is contained in:
parent
048aadf015
commit
e5ad03701d
1 changed files with 10 additions and 2 deletions
|
|
@ -32,6 +32,7 @@ import org.xnap.commons.i18n.I18n;
|
|||
import org.xnap.commons.i18n.I18nFactory;
|
||||
import org.zkoss.util.Locales;
|
||||
import org.zkoss.web.servlet.Charsets;
|
||||
import org.zkoss.zk.ui.Execution;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
|
||||
|
|
@ -42,8 +43,7 @@ public class I18nHelper {
|
|||
private static HashMap<Locale, I18n> localesCache = new HashMap<Locale, I18n>();
|
||||
|
||||
public static I18n getI18n() {
|
||||
Charsets.setPreferredLocale((HttpSession) Executions.getCurrent()
|
||||
.getSession().getNativeSession(), getUserLocale());
|
||||
setPreferredLocale();
|
||||
|
||||
Locale locale = Locales.getCurrent();
|
||||
|
||||
|
|
@ -65,6 +65,14 @@ public class I18nHelper {
|
|||
return i18n;
|
||||
}
|
||||
|
||||
private static void setPreferredLocale() {
|
||||
Execution execution = Executions.getCurrent();
|
||||
if (execution != null) {
|
||||
Charsets.setPreferredLocale((HttpSession) execution.getSession()
|
||||
.getNativeSession(), getUserLocale());
|
||||
}
|
||||
}
|
||||
|
||||
private static Locale getUserLocale() {
|
||||
User user = UserUtil.getUserFromSession();
|
||||
if (user != null) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue