public abstract class SelectedLocale extends Object
| Modifier and Type | Class and Description |
|---|---|
protected static class |
SelectedLocale.ContextSelectedLocale
Holds Locale information in the ServletContext.
|
protected static class |
SelectedLocale.SessionSelectedLocale
Holds Locale information in the Session.
|
| Modifier and Type | Field and Description |
|---|---|
protected static String |
ATTRIBUTE_NAME
Use this attribute on both the ServletContext and the Session.
|
| Constructor and Description |
|---|
SelectedLocale() |
| Modifier and Type | Method and Description |
|---|---|
static Locale |
getCurrentLocale(javax.servlet.http.HttpServletRequest req)
Get the current Locale to use, which is the first of these to be found:
The forced Locale in the servlet context
The selected Locale in the session
The Locale from the request
The default Locale for the JVM
|
static Locale |
getFallbackLocale() |
static Locale |
getOverridingLocale(javax.servlet.http.HttpServletRequest req)
Do we need to override the Locale in the current request? return the
first of these to be found:
The forced Locale in the servlet context
The selected Locale in the session
The first of the selectable Locales
null
|
static Locale |
getOverridingLocale(javax.servlet.ServletContext ctx,
List<Locale> preferredLocales)
Get the overriding Locale to use, which is the first of these to be found:
The forced Locale in the servlet context
The first selectable locale matching a preferred locale
The first of the preferred locale
null
|
static Locale |
getPreferredLocale(javax.servlet.ServletContext ctx,
List<Locale> preferredLocales)
Get the preferred Locale to use, which is the first of these to be found:
The forced Locale in the servlet context
The first selectable locale matching a preferred locale
The first of the preferred locale
The default Locale for the JVM
|
static List<Locale> |
getSelectableLocales(javax.servlet.http.HttpServletRequest req)
Get the list of selectable Locales from the servlet context.
|
static List<Locale> |
getSelectableLocales(javax.servlet.ServletContext ctx)
Get the list of selectable Locales from the servlet context.
|
static void |
setForcedLocale(javax.servlet.ServletContext ctx,
Locale forcedLocale)
Store the forced locale in the servlet context.
|
static void |
setSelectableLocales(javax.servlet.ServletContext ctx,
List<Locale> selectableLocales)
Store a list of selectable Locales in the servlet context, so we can
easily build the selection panel in the GUI.
|
static void |
setSelectedLocale(javax.servlet.http.HttpServletRequest req,
Locale selectedLocale)
Store the selected locale in the current session.
|
protected static final String ATTRIBUTE_NAME
public static void setForcedLocale(javax.servlet.ServletContext ctx,
Locale forcedLocale)
public static void setSelectedLocale(javax.servlet.http.HttpServletRequest req,
Locale selectedLocale)
public static Locale getOverridingLocale(javax.servlet.http.HttpServletRequest req)
public static Locale getOverridingLocale(javax.servlet.ServletContext ctx, List<Locale> preferredLocales)
public static Locale getFallbackLocale()
public static Locale getCurrentLocale(javax.servlet.http.HttpServletRequest req)
public static Locale getPreferredLocale(javax.servlet.ServletContext ctx, List<Locale> preferredLocales)
public static void setSelectableLocales(javax.servlet.ServletContext ctx,
List<Locale> selectableLocales)
public static List<Locale> getSelectableLocales(javax.servlet.http.HttpServletRequest req)
Copyright © 2021. All rights reserved.