com.opensymphony.webwork.interceptor
public class: FlashInterceptor [javadoc |
source]
java.lang.Object
com.opensymphony.xwork.interceptor.AroundInterceptor
com.opensymphony.webwork.interceptor.FlashInterceptor
Flash interceptor (
FlashInterceptor ) possibly with
FlashResult
allows current action to be available even after a redirect. It does this by
saving the current action into http session and pushing it back into the stack
next request, resulting in the nett effect of the action and its related information
being available across redirect.
There's no intended extension points
<!-- Usage 1: (Using only Flash interceptor) -->
<action name="store" ...>
<interceptor-ref name="flash">
<param name="operation">Store</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result type="redirect">redirectToSomeWhere.jsp</result>
</action>
<action name="retrieve">
<interceptor-ref name="flash">
<param name="operation">Retrieve</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result>pageWhereWeNeedFlashActionStored.jsp</result>
</action>
<!-- Usage 2: (Using Flash Interceptor and Flash Result) -->
<action name="store">
<result type="flash">redirectToSomeWhere.jsp</result>
</action>
<action name="retrieve">
<interceptor-ref name="flash">
<param name="operation">Retrieve</param>
</interceptor-ref>
<interceptor-ref name="defaultStack" />
<result>pageWhereWeNeedFlashActionStored.jsp</result>
</action>
- author:
tmjee -
- version:
$ - Date: 2007-02-04 13:33:20 +0800 (Sun, 04 Feb 2007) $ $Id: FlashInterceptor.java 2830 2007-02-04 05:33:20Z tm_jee $
| Field Summary |
|---|
| public static final String | DEFAULT_KEY | |
| public static final String | STORE | |
| public static final String | RETRIEVE | |
| Method from com.opensymphony.webwork.interceptor.FlashInterceptor Detail: |
protected void after(ActionInvocation invocation,
String result) throws Exception {
}
|
protected void before(ActionInvocation invocation) throws Exception {
Map sessionMap = ActionContext.getContext().getSession();
if (STORE.equalsIgnoreCase(operation)) {
invocation.addPreResultListener(new PreResultListener() {
public void beforeResult(ActionInvocation invocation, String resultCode) {
Map sessionMap = ActionContext.getContext().getSession();
Object action = invocation.getAction();
if (LOG.isDebugEnabled())
LOG.debug("inserting action ["+action+"] into session with key ["+key+"]");
sessionMap.put(key, action);
}
});
}
if (RETRIEVE.equalsIgnoreCase(operation)) {
if (sessionMap.get(key) != null) {
Object action = sessionMap.get(key);
if (LOG.isDebugEnabled()) {
LOG.debug("flash action with key ["+key+"] found in session, pushed action ["+action+"] into stack");
}
OgnlValueStack stack = (OgnlValueStack) ActionContext.getContext().get(ActionContext.VALUE_STACK);
stack.push(action);
sessionMap.remove(key);
if (LOG.isDebugEnabled()) {
LOG.debug("flash action with key ["+key+"] with actual type ["+action+"] removed from session after being pushed into the stack ");
}
}
else {
if (LOG.isDebugEnabled()) {
LOG.debug("flash action key ["+key+"] not found in session, no action is pushed into stack");
}
}
}
}
|
public String getKey() {
return this.key;
}
|
public String getOperation() {
return this.operation;
}
|
public void setKey(String key) {
this.key = key;
}
|
public void setOperation(String operation) {
this.operation = operation;
}
|