Home » xwork-2.1.5 » com.opensymphony » xwork2 » interceptor » [javadoc | source]
com.opensymphony.xwork2.interceptor
public class: I18nInterceptor [javadoc | source]
java.lang.Object
   com.opensymphony.xwork2.interceptor.AbstractInterceptor
      com.opensymphony.xwork2.interceptor.I18nInterceptor

All Implemented Interfaces:
    Interceptor

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 or, alternatively, only for the current request (since XWork 2.1.3). 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:

Extending the interceptor:

There are no known extensions points for this interceptor.

Example code:


<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 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     
Constructor:
 public I18nInterceptor() 
Method from com.opensymphony.xwork2.interceptor.I18nInterceptor Summary:
intercept,   saveLocale,   setAttributeName,   setParameterName,   setRequestOnlyParameterName
Methods from com.opensymphony.xwork2.interceptor.AbstractInterceptor:
destroy,   init,   intercept
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.opensymphony.xwork2.interceptor.I18nInterceptor Detail:
 public String intercept(ActionInvocation invocation) throws Exception 
 protected  void saveLocale(ActionInvocation invocation,
    Locale locale) 
    Save the given locale to the ActionInvocation.
 public  void setAttributeName(String attributeName) 
 public  void setParameterName(String parameterName) 
 public  void setRequestOnlyParameterName(String requestOnlyParameterName)