com.opensymphony.xwork.interceptor
Class ParameterRemoverInterceptor

java.lang.Object
  extended by com.opensymphony.xwork.interceptor.AroundInterceptor
      extended by com.opensymphony.xwork.interceptor.ParameterRemoverInterceptor
All Implemented Interfaces:
Interceptor, Serializable

public class ParameterRemoverInterceptor
extends AroundInterceptor

This is a simple WebWork interceptor that allows parameters (matching one of the paramNames attribute csv value) to be removed from the parameter map if they match a certain value (matching one of the paramValues attribute csv value), before they are set on the action. A typical usage would be to want a dropdown/select to map onto a boolean value on an action. The select had the options none, yes and no with values -1, true and false. The true and false would map across correctly. However the -1 would be set to false. This was not desired as one might needed the value on the action to stay null. This interceptor fixes this by preventing the parameter from ever reaching the action.

No intended extension point
 
        
 <action name="sample" class="org.martingilday.Sample">
        <interceptor-ref name="paramRemover">
                <param name="paramNames">aParam,anotherParam</param>
                <param name="paramValues">--,-1</param>
        </interceptor-ref>
        <interceptor-ref name="default-stack" />
        ...
 </action>
  
 
 

Version:
$Date$ $Id$
Author:
martin.gilday
See Also:
Serialized Form

Field Summary
 
Fields inherited from class com.opensymphony.xwork.interceptor.AroundInterceptor
log
 
Constructor Summary
ParameterRemoverInterceptor()
           
 
Method Summary
protected  void after(ActionInvocation dispatcher, String result)
          Empty implementation.
protected  void before(ActionInvocation invocation)
          Decide if the parameter should be removed from the parameter map based on paramNames and paramValues.
 void setParamNames(String paramNames)
          Allows paramNames attribute to be set as comma-separated-values (csv).
 void setParamValues(String paramValues)
          Allows paramValues attribute to be set as a comma-separated-values (csv).
 
Methods inherited from class com.opensymphony.xwork.interceptor.AroundInterceptor
destroy, init, intercept
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterRemoverInterceptor

public ParameterRemoverInterceptor()
Method Detail

after

protected void after(ActionInvocation dispatcher,
                     String result)
              throws Exception
Empty implementation.

Specified by:
after in class AroundInterceptor
result - the result value returned by the invocation
Throws:
Exception

before

protected void before(ActionInvocation invocation)
               throws Exception
Decide if the parameter should be removed from the parameter map based on paramNames and paramValues.

Specified by:
before in class AroundInterceptor
Throws:
Exception
See Also:
AroundInterceptor.before(com.opensymphony.xwork.ActionInvocation)

setParamNames

public void setParamNames(String paramNames)
Allows paramNames attribute to be set as comma-separated-values (csv).

Parameters:
paramNames - the paramNames to set

setParamValues

public void setParamValues(String paramValues)
Allows paramValues attribute to be set as a comma-separated-values (csv).

Parameters:
paramValues - the paramValues to set

WebWork Project Page