com.opensymphony.xwork2.interceptor
Class AliasInterceptor

java.lang.Object
  extended by com.opensymphony.xwork2.interceptor.AbstractInterceptor
      extended by com.opensymphony.xwork2.interceptor.AliasInterceptor
All Implemented Interfaces:
Interceptor, java.io.Serializable

public class AliasInterceptor
extends AbstractInterceptor

The aim of this Interceptor is to alias a named parameter to a different named parameter. By acting as the glue between actions sharing similiar parameters (but with different names), it can help greatly with action chaining.

Action's alias expressions should be in the form of #{ "name1" : "alias1", "name2" : "alias2" }. This means that assuming an action (or something else in the stack) has a value for the expression named name1 and the action this interceptor is applied to has a setter named alias1, alias1 will be set with the value from name1.

Interceptor parameters:

Extending the interceptor:

This interceptor does not have any known extension points.

Example code:

 
 <action name="someAction" class="com.examples.SomeAction">
     <!-- The value for the foo parameter will be applied as if it were named bar -->
     <param name="aliases">#{ 'foo' : 'bar' }</param>

     <interceptor-ref name="alias"/>
     <interceptor-ref name="basicStack"/>
     <result name="success">good_result.ftl</result>
 </action>
 
 

Author:
Matthew Payne
See Also:
Serialized Form

Field Summary
protected  java.lang.String aliasesKey
           
protected  ValueStackFactory valueStackFactory
           
 
Constructor Summary
AliasInterceptor()
           
 
Method Summary
 java.lang.String intercept(ActionInvocation invocation)
          Override to handle interception
 void setAliasesKey(java.lang.String aliasesKey)
          Sets the name of the action parameter to look for the alias map.
static void setDevMode(java.lang.String mode)
           
 void setValueStackFactory(ValueStackFactory valueStackFactory)
           
 
Methods inherited from class com.opensymphony.xwork2.interceptor.AbstractInterceptor
destroy, init
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

aliasesKey

protected java.lang.String aliasesKey

valueStackFactory

protected ValueStackFactory valueStackFactory
Constructor Detail

AliasInterceptor

public AliasInterceptor()
Method Detail

setDevMode

public static void setDevMode(java.lang.String mode)

setValueStackFactory

public void setValueStackFactory(ValueStackFactory valueStackFactory)

setAliasesKey

public void setAliasesKey(java.lang.String aliasesKey)
Sets the name of the action parameter to look for the alias map.

Default is aliases.

Parameters:
aliasesKey - the name of the action parameter

intercept

public java.lang.String intercept(ActionInvocation invocation)
                           throws java.lang.Exception
Description copied from class: AbstractInterceptor
Override to handle interception

Specified by:
intercept in interface Interceptor
Specified by:
intercept in class AbstractInterceptor
Parameters:
invocation - the action invocation
Returns:
the return code, either returned from ActionInvocation.invoke(), or from the interceptor itself.
Throws:
java.lang.Exception - any system-level error, as defined in Action.execute().


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.