public class I18nInterceptor extends AbstractInterceptor
Modifier and Type | Class and Description |
---|---|
protected class |
I18nInterceptor.CookieLocaleHandler |
protected static interface |
I18nInterceptor.LocaleHandler
Uses to handle reading/storing Locale from/in different locations
|
protected class |
I18nInterceptor.RequestOnlyLocaleHandler |
protected class |
I18nInterceptor.SessionLocaleHandler |
protected static class |
I18nInterceptor.Storage |
Modifier and Type | Field and Description |
---|---|
protected String |
attributeName |
static String |
DEFAULT_COOKIE_ATTRIBUTE |
static String |
DEFAULT_COOKIE_PARAMETER |
static String |
DEFAULT_PARAMETER |
static String |
DEFAULT_REQUEST_ONLY_PARAMETER |
static String |
DEFAULT_SESSION_ATTRIBUTE |
protected LocaleProviderFactory |
localeProviderFactory |
protected String |
parameterName |
protected String |
requestCookieParameterName |
protected String |
requestOnlyParameterName |
protected I18nInterceptor.Storage |
storage |
Constructor and Description |
---|
I18nInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected Parameter |
findLocaleParameter(ActionInvocation invocation,
String parameterName) |
protected Locale |
getLocaleFromParam(Object requestedLocale)
Creates a Locale object from the request param, which might
be already a Local or a String
|
protected I18nInterceptor.LocaleHandler |
getLocaleHandler(ActionInvocation invocation)
Override this method to use your own implementation of
I18nInterceptor.LocaleHandler |
String |
intercept(ActionInvocation invocation)
Override to handle interception
|
void |
setAttributeName(String attributeName) |
void |
setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory) |
void |
setLocaleStorage(String storageName) |
void |
setParameterName(String parameterName) |
void |
setRequestCookieParameterName(String requestCookieParameterName) |
void |
setRequestOnlyParameterName(String requestOnlyParameterName) |
protected void |
useLocale(ActionInvocation invocation,
Locale locale)
Save the given locale to the ActionInvocation.
|
destroy, init
public static final String DEFAULT_SESSION_ATTRIBUTE
public static final String DEFAULT_PARAMETER
public static final String DEFAULT_REQUEST_ONLY_PARAMETER
public static final String DEFAULT_COOKIE_ATTRIBUTE
public static final String DEFAULT_COOKIE_PARAMETER
protected String parameterName
protected String requestOnlyParameterName
protected String attributeName
protected String requestCookieParameterName
protected I18nInterceptor.Storage storage
protected LocaleProviderFactory localeProviderFactory
public void setParameterName(String parameterName)
public void setAttributeName(String attributeName)
public void setRequestOnlyParameterName(String requestOnlyParameterName)
public void setRequestCookieParameterName(String requestCookieParameterName)
public void setLocaleStorage(String storageName)
public void setLocaleProviderFactory(LocaleProviderFactory localeProviderFactory)
public String intercept(ActionInvocation invocation) throws Exception
AbstractInterceptor
intercept
in interface Interceptor
intercept
in class AbstractInterceptor
invocation
- the action invocationActionInvocation.invoke()
, or from the interceptor itself.Exception
- any system-level error, as defined in Action.execute()
.protected I18nInterceptor.LocaleHandler getLocaleHandler(ActionInvocation invocation)
I18nInterceptor.LocaleHandler
invocation
- current action invocation contextI18nInterceptor.LocaleHandler
protected Locale getLocaleFromParam(Object requestedLocale)
requestedLocale
- the parameter from the requestprotected Parameter findLocaleParameter(ActionInvocation invocation, String parameterName)
protected void useLocale(ActionInvocation invocation, Locale locale)
invocation
- The ActionInvocation.locale
- The locale to save.Copyright © 2000–2020 Apache Software Foundation. All rights reserved.