Package org.apache.struts2.interceptor
Class I18nInterceptor
java.lang.Object
org.apache.struts2.interceptor.AbstractInterceptor
org.apache.struts2.interceptor.I18nInterceptor
- All Implemented Interfaces:
Serializable
,ConditionalInterceptor
,Interceptor
An interceptor that handles setting the locale specified in a session as the locale for the current action request.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected class
protected class
protected static interface
Uses to handle reading/storing Locale from/in different locationsprotected class
protected class
protected static enum
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected Parameter
findLocaleParameter
(ActionInvocation invocation, String parameterName) protected Locale
getLocaleFromParam
(String requestedLocale) Creates a Locale object from the request paramprotected I18nInterceptor.LocaleHandler
getLocaleHandler
(ActionInvocation invocation) Override this method to use your own implementation ofI18nInterceptor.LocaleHandler
intercept
(ActionInvocation invocation) Override to handle interceptionvoid
setAttributeName
(String attributeName) void
setLocaleProviderFactory
(LocaleProviderFactory localeProviderFactory) void
setLocaleStorage
(String storageName) void
setParameterName
(String parameterName) void
setRequestCookieParameterName
(String requestCookieParameterName) void
setRequestOnlyParameterName
(String requestOnlyParameterName) void
setSupportedLocale
(String supportedLocale) Sets supported Locales by the applicationprotected void
useLocale
(ActionInvocation invocation, Locale locale) Save the given locale to the ActionInvocation.Methods inherited from class org.apache.struts2.interceptor.AbstractInterceptor
destroy, init, setDisabled, shouldIntercept
-
Field Details
-
DEFAULT_SESSION_ATTRIBUTE
- See Also:
-
DEFAULT_PARAMETER
- See Also:
-
DEFAULT_REQUEST_ONLY_PARAMETER
- See Also:
-
DEFAULT_COOKIE_ATTRIBUTE
- See Also:
-
DEFAULT_COOKIE_PARAMETER
- See Also:
-
parameterName
-
requestOnlyParameterName
-
attributeName
-
requestCookieParameterName
-
storage
-
localeProviderFactory
-
-
Constructor Details
-
I18nInterceptor
public I18nInterceptor()
-
-
Method Details
-
setParameterName
-
setAttributeName
-
setRequestOnlyParameterName
-
setRequestCookieParameterName
-
setLocaleStorage
-
setSupportedLocale
Sets supported Locales by the application- Parameters:
supportedLocale
- a comma separated list of supported Locale
-
setLocaleProviderFactory
-
intercept
Description copied from class:AbstractInterceptor
Override to handle interception- Specified by:
intercept
in interfaceInterceptor
- Specified by:
intercept
in classAbstractInterceptor
- Parameters:
invocation
- the action invocation- Returns:
- the return code, either returned from
ActionInvocation.invoke()
, or from the interceptor itself. - Throws:
Exception
- any system-level error, as defined inAction.execute()
.
-
getLocaleHandler
Override this method to use your own implementation ofI18nInterceptor.LocaleHandler
- Parameters:
invocation
- current action invocation context- Returns:
- instance of
I18nInterceptor.LocaleHandler
-
getLocaleFromParam
Creates a Locale object from the request param- Parameters:
requestedLocale
- the parameter from the request- Returns:
- instance of
Locale
or null
-
findLocaleParameter
-
useLocale
Save the given locale to the ActionInvocation.- Parameters:
invocation
- The ActionInvocation.locale
- The locale to save.
-