Details
-
Type: Bug
-
Status: Closed
-
Priority: Minor
-
Resolution: Fixed
-
Affects Version/s: 3.3, EE-3.3.0.GA
-
Fix Version/s: EE-3.3.0.GA, 4.0.BETA, 4.0
-
Component/s: Sample Apps
-
Labels:None
-
Environment:Chat sample app
-
Assignee Priority:P3
-
Affects:Sample App./Tutorial
Description
The chat sample supports internationalizing messages but tries to use the FacesContext to determine the Locale during logout:
public static String getLocalizedMessage(String messagePatternKey, String[] messageArgs){
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
Locale locale = root.getLocale();
String localizedPattern = ResourceUtil.getI18NString(locale,messagePatternKey);
return MessageFormat.format(localizedPattern,(Object[])messageArgs);
}
When a session expires, the container thread does not have a FacesContext leading to the NPE. We need to check for FacesContext in this case and just use the default locale.
public static String getLocalizedMessage(String messagePatternKey, String[] messageArgs){
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
Locale locale = root.getLocale();
String localizedPattern = ResourceUtil.getI18NString(locale,messagePatternKey);
return MessageFormat.format(localizedPattern,(Object[])messageArgs);
}
When a session expires, the container thread does not have a FacesContext leading to the NPE. We need to check for FacesContext in this case and just use the default locale.
Activity
- All
- Comments
- History
- Activity
- Remote Attachments
- Subversion