com.opensymphony.xwork2.interceptor
Class StaticParametersInterceptor

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

public class StaticParametersInterceptor
extends AbstractInterceptor

This interceptor populates the action with the static parameters defined in the action configuration. If the action implements Parameterizable, a map of the static parameters will be also be passed directly to the action. The static params will be added to the request params map, unless "merge" is set to false.

Parameters are typically defined with <param> elements within xwork.xml.

Interceptor parameters:

Extending the interceptor:

There are no extension points to this interceptor.

Example code:

 
 <action name="someAction" class="com.examples.SomeAction">
     <interceptor-ref name="staticParams">
          <param name="parse">true</param>
          <param name="overwrite">false</param>
     </interceptor-ref>
     <result name="success">good_result.ftl</result>
 </action>
 
 

Author:
Patrick Lightbody
See Also:
Serialized Form

Constructor Summary
StaticParametersInterceptor()
           
 
Method Summary
protected  void addParametersToContext(ActionContext ac, java.util.Map<java.lang.String,?> newParams)
          Adds the parameters into context's ParameterMap.
 java.lang.String intercept(ActionInvocation invocation)
          Override to handle interception
protected  java.util.Map<java.lang.String,java.lang.String> retrieveParameters(ActionContext ac)
           
static void setDevMode(java.lang.String mode)
           
 void setMerge(java.lang.String value)
           
 void setOverwrite(java.lang.String value)
          Overwrites already existing parameters from other sources.
 void setParse(java.lang.String value)
           
 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
 

Constructor Detail

StaticParametersInterceptor

public StaticParametersInterceptor()
Method Detail

setValueStackFactory

public void setValueStackFactory(ValueStackFactory valueStackFactory)

setDevMode

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

setParse

public void setParse(java.lang.String value)

setMerge

public void setMerge(java.lang.String value)

setOverwrite

public void setOverwrite(java.lang.String value)
Overwrites already existing parameters from other sources. Static parameters are the successor over previously set parameters, if true.

Parameters:
value -

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().

retrieveParameters

protected java.util.Map<java.lang.String,java.lang.String> retrieveParameters(ActionContext ac)
Parameters:
ac - The action context
Returns:
the parameters from the action mapping in the context. If none found, returns an empty map.

addParametersToContext

protected void addParametersToContext(ActionContext ac,
                                      java.util.Map<java.lang.String,?> newParams)
Adds the parameters into context's ParameterMap. As default, static parameters will not overwrite existing paramaters from other sources. If you want the static parameters as successor over already existing parameters, set overwrite to true.

Parameters:
ac - The action context
newParams - The parameter map to apply


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