com.opensymphony.xwork2.interceptor
protected static class: ModelDrivenInterceptor.RefreshModelBeforeResult [javadoc |
source]
java.lang.Object
com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor$RefreshModelBeforeResult
All Implemented Interfaces:
PreResultListener
Refreshes the model instance on the value stack, if it has changed
Field Summary |
---|
protected ModelDriven | action | |
Method from com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor$RefreshModelBeforeResult Summary: |
---|
beforeResult |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor$RefreshModelBeforeResult Detail: |
public void beforeResult(ActionInvocation invocation,
String resultCode) {
ValueStack stack = invocation.getStack();
CompoundRoot root = stack.getRoot();
boolean needsRefresh = true;
Object newModel = action.getModel();
// Check to see if the new model instance is already on the stack
for (Object item : root) {
if (item.equals(newModel)) {
needsRefresh = false;
}
}
// Add the new model on the stack
if (needsRefresh) {
// Clear off the old model instance
if (originalModel != null) {
root.remove(originalModel);
}
if (newModel != null) {
stack.push(newModel);
}
}
}
|