com.opensymphony.xwork2.interceptor
public class: StaticParametersInterceptor [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor
All Implemented Interfaces:
Interceptor
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.
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>
</interceptor-ref>
<result name="success">good_result.ftl</result>
</action>
- author:
Patrick - Lightbody
| Method from com.opensymphony.xwork2.interceptor.StaticParametersInterceptor Summary: |
|---|
|
intercept, setParse |
| Method from com.opensymphony.xwork2.interceptor.StaticParametersInterceptor Detail: |
public String intercept(ActionInvocation invocation) throws Exception {
ActionConfig config = invocation.getProxy().getConfig();
Object action = invocation.getAction();
final Map parameters = config.getParams();
if (LOG.isDebugEnabled()) {
LOG.debug("Setting static parameters " + parameters);
}
// for actions marked as Parameterizable, pass the static parameters directly
if (action instanceof Parameterizable) {
((Parameterizable) action).setParams(parameters);
}
if (parameters != null) {
final ValueStack stack = ActionContext.getContext().getValueStack();
for (Iterator iterator = parameters.entrySet().iterator();
iterator.hasNext();) {
Map.Entry entry = (Map.Entry) iterator.next();
stack.setValue(entry.getKey().toString(), entry.getValue());
Object val = entry.getValue();
if (parse && val instanceof String) {
val = TextParseUtil.translateVariables((String) val, stack);
}
stack.setValue(entry.getKey().toString(), val);
}
}
return invocation.invoke();
}
|
public void setParse(String value) {
this.parse = Boolean.valueOf(value).booleanValue();
}
|