Author: ghuber
Date: Thu Sep 13 13:36:11 2012
New Revision: 1384321
URL: http://svn.apache.org/viewvc?rev=1384321&view=rev
Log:
Do not call myPrepare() on a cancel.
Modified:
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/util/UIActionPrepareInterceptor.java
roller/trunk/weblogger-web/src/main/resources/struts.xml
Modified:
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/util/UIActionPrepareInterceptor.java
URL:
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/util/UIActionPrepareInterceptor.java?rev=1384321&r1=1384320&r2=1384321&view=diff
==============================================================================
---
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/util/UIActionPrepareInterceptor.java
(original)
+++
roller/trunk/weblogger-web/src/main/java/org/apache/roller/weblogger/ui/struts2/util/UIActionPrepareInterceptor.java
Thu Sep 13 13:36:11 2012
@@ -18,57 +18,58 @@
package org.apache.roller.weblogger.ui.struts2.util;
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.ActionInvocation;
-import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.ui.struts2.editor.EntryAdd;
import org.apache.roller.weblogger.ui.struts2.editor.EntryAddWithMediaFile;
import org.apache.roller.weblogger.ui.struts2.editor.EntryEdit;
+import com.opensymphony.xwork2.ActionInvocation;
+import com.opensymphony.xwork2.interceptor.MethodFilterInterceptor;
/**
* A struts2 interceptor for doing custom prepare logic.
*/
-public class UIActionPrepareInterceptor extends AbstractInterceptor {
-
- private static Log log =
LogFactory.getLog(UIActionPrepareInterceptor.class);
-
-
- public String intercept(ActionInvocation invocation) throws Exception {
-
- log.debug("Entering UIActionPrepareInterceptor");
-
- final Object action = invocation.getAction();
- final ActionContext context = invocation.getInvocationContext();
-
- // is this one of our own UIAction classes?
- if (action instanceof UIActionPreparable) {
-
- log.debug("action is UIActionPreparable, calling myPrepare()
method");
-
- // The EntryAdd->EntryEdit chain is the one place where we need
- // to pass a parameter along the chain, thus this somewhat ugly
hack
- if (invocation.getStack().getRoot().size() > 1) {
- Object action0= invocation.getStack().getRoot().get(0);
- Object action1 = invocation.getStack().getRoot().get(1);
- if (action0 instanceof EntryEdit && action1 instanceof
EntryAdd) {
- EntryEdit editAction = (EntryEdit)action0;
- EntryAdd addAction = (EntryAdd)action1;
- editAction.getBean().setId(addAction.getBean().getId());
- } else if (action0 instanceof EntryAdd && action1 instanceof
EntryAddWithMediaFile) {
- EntryAdd addAction = (EntryAdd)action0;
- EntryAddWithMediaFile mediaAction =
(EntryAddWithMediaFile)action1;
- addAction.setBean(mediaAction.getBean());
- }
- }
-
- UIActionPreparable theAction = (UIActionPreparable) action;
- theAction.myPrepare();
- }
-
- return invocation.invoke();
- }
-
+public class UIActionPrepareInterceptor extends MethodFilterInterceptor {
+
+ private static final long serialVersionUID = 7770184756145702592L;
+ private static Log log = LogFactory
+ .getLog(UIActionPrepareInterceptor.class);
+
+ public String doIntercept(ActionInvocation invocation) throws Exception
{
+
+ log.debug("Entering UIActionPrepareInterceptor");
+
+ final Object action = invocation.getAction();
+ //final ActionContext context =
invocation.getInvocationContext();
+
+ // is this one of our own UIAction classes?
+ if (action instanceof UIActionPreparable) {
+
+ log.debug("action is UIActionPreparable, calling
myPrepare() method");
+
+ // The EntryAdd->EntryEdit chain is the one place where
we need
+ // to pass a parameter along the chain, thus this
somewhat ugly hack
+ if (invocation.getStack().getRoot().size() > 1) {
+ Object action0 =
invocation.getStack().getRoot().get(0);
+ Object action1 =
invocation.getStack().getRoot().get(1);
+ if (action0 instanceof EntryEdit && action1
instanceof EntryAdd) {
+ EntryEdit editAction = (EntryEdit)
action0;
+ EntryAdd addAction = (EntryAdd) action1;
+
editAction.getBean().setId(addAction.getBean().getId());
+ } else if (action0 instanceof EntryAdd
+ && action1 instanceof
EntryAddWithMediaFile) {
+ EntryAdd addAction = (EntryAdd) action0;
+ EntryAddWithMediaFile mediaAction =
(EntryAddWithMediaFile) action1;
+
addAction.setBean(mediaAction.getBean());
+ }
+ }
+
+ UIActionPreparable theAction = (UIActionPreparable)
action;
+ theAction.myPrepare();
+ }
+
+ return invocation.invoke();
+ }
+
}
Modified: roller/trunk/weblogger-web/src/main/resources/struts.xml
URL:
http://svn.apache.org/viewvc/roller/trunk/weblogger-web/src/main/resources/struts.xml?rev=1384321&r1=1384320&r2=1384321&view=diff
==============================================================================
--- roller/trunk/weblogger-web/src/main/resources/struts.xml (original)
+++ roller/trunk/weblogger-web/src/main/resources/struts.xml Thu Sep 13
13:36:11 2012
@@ -47,7 +47,9 @@
<!-- custom Roller interceptors -->
<interceptor-ref name="UIActionInterceptor"/>
<interceptor-ref name="UISecurityInterceptor"/>
- <interceptor-ref name="UIActionPrepareInterceptor"/>
+ <interceptor-ref name="UIActionPrepareInterceptor">
+ <param
name="excludeMethods">input,back,cancel,browse</param>
+ </interceptor-ref>
<!-- validation interceptors, MUST come after our custom
interceptors -->
<interceptor-ref name="validation">