You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2006/03/08 02:49:50 UTC

svn commit: r384088 - in /struts/extras/trunk/src/java/org/apache/struts/actions: DispatchAction.java LookupDispatchAction.java

Author: niallp
Date: Tue Mar  7 17:49:48 2006
New Revision: 384088

URL: http://svn.apache.org/viewcvs?rev=384088&view=rev
Log:
DispatchAction refactoring and remove duplicated LookupDispatchAction code

Modified:
    struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java
    struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java?rev=384088&r1=384087&r2=384088&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/DispatchAction.java Tue Mar  7 17:49:48 2006
@@ -147,17 +147,8 @@
             }
         }
 
-        // Identify the request parameter containing the method name
-        String parameter = mapping.getParameter();
-
-        if (parameter == null) {
-            String message =
-                messages.getMessage("dispatch.handler", mapping.getPath());
-
-            log.error(message);
-
-            throw new ServletException(message);
-        }
+        // Get the parameter. This could be overridden in subclasses.
+        String parameter = getParameter(mapping, form, request, response);
 
         // Get the method's name. This could be overridden in subclasses.
         String name =
@@ -304,6 +295,36 @@
 
         // Return the returned ActionForward instance
         return (forward);
+    }
+
+    /**
+     * <p>Returns the parameter value.</p>
+     *
+     * @param mapping  The ActionMapping used to select this instance
+     * @param form     The optional ActionForm bean for this request (if any)
+     * @param request  The HTTP request we are processing
+     * @param response The HTTP response we are creating
+     * @return The <code>ActionMapping</code> parameter's value
+     * @throws Exception if the parameter is missing.
+     */
+    protected String getParameter(ActionMapping mapping, ActionForm form,
+        HttpServletRequest request, HttpServletResponse response)
+        throws Exception {
+
+        // Identify the request parameter containing the method name
+        String parameter = mapping.getParameter();
+
+        if (parameter == null) {
+            String message =
+                messages.getMessage("dispatch.handler", mapping.getPath());
+
+            log.error(message);
+
+            throw new ServletException(message);
+        }
+
+
+        return parameter;
     }
 
     /**

Modified: struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java?rev=384088&r1=384087&r2=384088&view=diff
==============================================================================
--- struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java (original)
+++ struts/extras/trunk/src/java/org/apache/struts/actions/LookupDispatchAction.java Tue Mar  7 17:49:48 2006
@@ -109,7 +109,7 @@
     /**
      * Commons Logging instance.
      */
-    private static Log LOG = LogFactory.getLog(LookupDispatchAction.class);
+    private static final Log LOG = LogFactory.getLog(LookupDispatchAction.class);
 
     /**
      * Reverse lookup map from resource value to resource key.
@@ -140,29 +140,7 @@
     public ActionForward execute(ActionMapping mapping, ActionForm form,
         HttpServletRequest request, HttpServletResponse response)
         throws Exception {
-        if (isCancelled(request)) {
-            ActionForward af = cancelled(mapping, form, request, response);
-
-            if (af != null) {
-                return af;
-            }
-        }
-
-        // Identify the request parameter containing the method name
-        String parameter = mapping.getParameter();
-
-        if (parameter == null) {
-            String message =
-                messages.getMessage("dispatch.handler", mapping.getPath());
-
-            throw new ServletException(message);
-        }
-
-        // Identify the string to lookup
-        String methodName =
-            getMethodName(mapping, form, request, response, parameter);
-
-        return dispatchMethod(mapping, form, request, response, methodName);
+        return super.execute(mapping, form, request, response);
     }
 
     /**



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org