com.opensymphony.xwork2.interceptor
public class: ModelDrivenInterceptor [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.interceptor.AbstractInterceptor
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor
All Implemented Interfaces:
Interceptor
Watches for
ModelDriven actions and adds the action's model on to the value stack.
Note: The ModelDrivenInterceptor must come before the both
StaticParametersInterceptor and
ParametersInterceptor if you want the parameters to be applied to the model.
Note: The ModelDrivenInterceptor will only push the model into the stack when the
model is not null, else it will be ignored.
Interceptor parameters:
- refreshModelBeforeResult - set to true if you want the model to be refreshed on the value stack after action
execution and before result execution. The setting is useful if you want to change the model instance during the
action execution phase, like when loading it from the data layer. This will result in getModel() being called at
least twice.
Extending the interceptor:
There are no known extension points to this interceptor.
Example code:
<action name="someAction" class="com.examples.SomeAction">
<interceptor-ref name="modelDriven"/>
<interceptor-ref name="basicStack"/>
<result name="success">good_result.ftl</result>
</action>
- author:
tm_jee
-
- version:
$
- Date: 2009-07-28 02:25:13 +0200 (Di, 28 Jul 2009) $ $Id: ModelDrivenInterceptor.java 2027 2009-07-28 00:25:13Z musachy $
Field Summary |
---|
protected boolean | refreshModelBeforeResult | |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor Detail: |
public String intercept(ActionInvocation invocation) throws Exception {
Object action = invocation.getAction();
if (action instanceof ModelDriven) {
ModelDriven modelDriven = (ModelDriven) action;
ValueStack stack = invocation.getStack();
Object model = modelDriven.getModel();
if (model != null) {
stack.push(model);
}
if (refreshModelBeforeResult) {
invocation.addPreResultListener(new RefreshModelBeforeResult(modelDriven, model));
}
}
return invocation.invoke();
}
|
public void setRefreshModelBeforeResult(boolean val) {
this.refreshModelBeforeResult = val;
}
|