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:50:53 UTC
svn commit: r384089 - in
/struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions:
DispatchAction.java LookupDispatchAction.java
Author: niallp
Date: Tue Mar 7 17:50:52 2006
New Revision: 384089
URL: http://svn.apache.org/viewcvs?rev=384089&view=rev
Log:
DispatchAction refactoring and remove duplicated LookupDispatchAction code
Modified:
struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/DispatchAction.java
struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/LookupDispatchAction.java
Modified: struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/DispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/DispatchAction.java?rev=384089&r1=384088&r2=384089&view=diff
==============================================================================
--- struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/DispatchAction.java (original)
+++ struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/DispatchAction.java Tue Mar 7 17:50:52 2006
@@ -165,16 +165,9 @@
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());
-
- 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 = getMethodName(mapping, form, request, response, parameter);
@@ -306,6 +299,35 @@
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;
+ }
/**
* Introspect the current class to identify a method of the specified
Modified: struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/LookupDispatchAction.java
URL: http://svn.apache.org/viewcvs/struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/LookupDispatchAction.java?rev=384089&r1=384088&r2=384089&view=diff
==============================================================================
--- struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/LookupDispatchAction.java (original)
+++ struts/action/branches/STRUTS_1_2_BRANCH/src/share/org/apache/struts/actions/LookupDispatchAction.java Tue Mar 7 17:50:52 2006
@@ -113,7 +113,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.
@@ -147,25 +147,7 @@
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