public class I18nInterceptor extends AbstractInterceptor
<action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="i18n"/> <interceptor-ref name="basicStack"/> <result name="success">good_result.ftl</result> </action>
Modifier and Type | Class and Description |
---|---|
protected class |
I18nInterceptor.LocaleFinder |
protected static class |
I18nInterceptor.Storage |
Modifier and Type | Field and Description |
---|---|
protected String |
attributeName |
static String |
DEFAULT_PARAMETER |
static String |
DEFAULT_REQUESTONLY_PARAMETER |
static String |
DEFAULT_SESSION_ATTRIBUTE |
protected static Logger |
LOG |
protected String |
parameterName |
protected String |
requestOnlyParameterName |
Constructor and Description |
---|
I18nInterceptor() |
Modifier and Type | Method and Description |
---|---|
protected Object |
findLocaleParameter(Map<String,Object> params,
String parameterName) |
protected Locale |
getLocaleFromParam(Object requestedLocale)
Creates a Locale object from the request param, which might
be already a Local or a String
|
String |
intercept(ActionInvocation invocation)
Override to handle interception
|
protected Locale |
readStoredLocale(ActionInvocation invocation,
Map<String,Object> session)
Reads the locale from the session, and if not found from the
current invocation (=browser)
|
protected Locale |
readStoredLocalFromCurrentInvocation(ActionInvocation invocation) |
protected Locale |
readStoredLocalFromSession(ActionInvocation invocation,
Map<String,Object> session) |
protected void |
saveLocale(ActionInvocation invocation,
Locale locale)
Save the given locale to the ActionInvocation.
|
void |
setAttributeName(String attributeName) |
void |
setParameterName(String parameterName) |
void |
setRequestOnlyParameterName(String requestOnlyParameterName) |
protected Locale |
storeLocale(ActionInvocation invocation,
Locale locale,
String storage)
Store the locale to the chosen storage, like f.
|
destroy, init
protected static final Logger LOG
public static final String DEFAULT_SESSION_ATTRIBUTE
public static final String DEFAULT_PARAMETER
public static final String DEFAULT_REQUESTONLY_PARAMETER
protected String parameterName
protected String requestOnlyParameterName
protected String attributeName
public void setParameterName(String parameterName)
public void setRequestOnlyParameterName(String requestOnlyParameterName)
public void setAttributeName(String attributeName)
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 Locale storeLocale(ActionInvocation invocation, Locale locale, String storage)
invocation
- the action invocationlocale
- the locale to storestorage
- the place to store this locale (like Storage.SESSSION.toString())protected Locale getLocaleFromParam(Object requestedLocale)
requestedLocale
- the parameter from the requestprotected Locale readStoredLocale(ActionInvocation invocation, Map<String,Object> session)
invocation
- the current invocationsession
- the current sessionprotected Locale readStoredLocalFromSession(ActionInvocation invocation, Map<String,Object> session)
protected Locale readStoredLocalFromCurrentInvocation(ActionInvocation invocation)
protected Object findLocaleParameter(Map<String,Object> params, String parameterName)
protected void saveLocale(ActionInvocation invocation, Locale locale)
invocation
- The ActionInvocation.locale
- The locale to save.Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.