|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork.interceptor.I18nInterceptor
An interceptor that handles setting the locale specified in a session as the locale for the current action request. In addition, this interceptor will look for a specific HTTP request parameter and set the locale to whatever value is provided. This means that this interceptor can be used to allow for your application to dynamically change the locale for the user's session. This is very useful for applications that require multi-lingual support and want the user to be able to set his or her language preference at any point. The locale parameter is removed during the execution of this interceptor, ensuring that properties aren't set on an action (such as request_locale) that have no typical corresponding setter in your action.
For example, using the default parameter name, a request to foo.action?request_locale=en_US, then the locale for US English is saved in the user's session and will be used for all future requests. Interceptor parameters:<action name="someAction" class="com.examples.SomeAction"> <interceptor-ref name="i18n"/> <interceptor-ref name="basicStack"/> <result name="success">good_result.ftl</result> </action>
Field Summary | |
protected String |
attributeName
|
static String |
DEFAULT_PARAMETER
|
static String |
DEFAULT_SESSION_ATTRIBUTE
|
protected static org.apache.commons.logging.Log |
log
|
protected String |
parameterName
|
Constructor Summary | |
I18nInterceptor()
|
Method Summary | |
void |
destroy()
Called to let an interceptor clean up any resources it has allocated. |
void |
init()
Called after an interceptor is created, but before any requests are processed using intercept , giving
the Interceptor a chance to initialize any needed resources. |
String |
intercept(ActionInvocation invocation)
Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the request by the ActionInvocation or to short-circuit the processing and just return a String return code. |
protected void |
saveLocale(ActionInvocation invocation,
Locale locale)
Save the given locale to the ActionInvocation. |
void |
setAttributeName(String attributeName)
|
void |
setParameterName(String parameterName)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final org.apache.commons.logging.Log log
public static final String DEFAULT_SESSION_ATTRIBUTE
public static final String DEFAULT_PARAMETER
protected String parameterName
protected String attributeName
Constructor Detail |
public I18nInterceptor()
Method Detail |
public void setParameterName(String parameterName)
public void setAttributeName(String attributeName)
public void init()
Interceptor
intercept
, giving
the Interceptor a chance to initialize any needed resources.
init
in interface Interceptor
public void destroy()
Interceptor
destroy
in interface Interceptor
public String intercept(ActionInvocation invocation) throws Exception
Interceptor
ActionInvocation
or to short-circuit the processing and just return a String return code.
intercept
in interface Interceptor
ActionInvocation.invoke()
, or from the interceptor itself.
Exception
- any system-level error, as defined in Action.execute()
.protected void saveLocale(ActionInvocation invocation, Locale locale)
invocation
- The ActionInvocation.locale
- The locale to save.
|
XWork Project Page | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |