rleland     2003/08/12 22:29:27

  Modified:    src/share/org/apache/struts/actions DispatchAction.java
                        LookupDispatchAction.java
  Log:
  Bug 18002
  
  Leave default Struts behavour the same ie
  no exception thrown when cancel is hit.
  
  Revision  Changes    Path
  1.18      +22 -26    
jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java
  
  Index: DispatchAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/actions/DispatchAction.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DispatchAction.java       13 Aug 2003 04:53:43 -0000      1.17
  +++ DispatchAction.java       13 Aug 2003 05:29:27 -0000      1.18
  @@ -134,6 +134,7 @@
    * @author Craig R. McClanahan
    * @author Ted Husted
    * @author Leonardo Quijano
  + * @author Rob Leland
    * @version $Revision$ $Date$
    */
   public abstract class DispatchAction extends Action {
  @@ -206,27 +207,29 @@
                                    HttpServletRequest request,
                                    HttpServletResponse response)
               throws Exception {
  -
           if (isCancelled(request)) {
  -            return cancelled(mapping, form, request, response);
  -        } else {
  -            // 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);
  +            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());
   
  -            // Get the method's name. This could be overridden in subclasses.
  -            String name = getMethodName(mapping, form, request, response, 
parameter);
  +            log.error(message);
   
  -            // Invoke the named method, and return the result
  -            return dispatchMethod(mapping, form, request, response, name);
  +            throw new ServletException(message);
           }
  +
  +        // Get the method's name. This could be overridden in subclasses.
  +        String name = getMethodName(mapping, form, request, response, parameter);
  +
  +        // Invoke the named method, and return the result
  +        return dispatchMethod(mapping, form, request, response, name);
  +
       }
   
   
  @@ -259,7 +262,7 @@
        * Subclasses of <code>DispatchAction</code> should override this method if
        * they wish to provide default behavior different than throwing a
        * ServletException.
  -     *
  +     * @since Struts 1.2.1
        */
       protected ActionForward cancelled(ActionMapping mapping,
                                         ActionForm form,
  @@ -267,15 +270,7 @@
                                         HttpServletResponse response)
               throws Exception {
   
  -        String message =
  -                messages.getMessage(
  -                        "dispatch.cancelled",
  -                        mapping.getPath(),
  -                        mapping.getParameter());
  -
  -        log.error(message);
  -
  -        throw new ServletException(message);
  +        return null;
       }
   
       // ----------------------------------------------------- Protected Methods
  @@ -378,6 +373,7 @@
        * @param parameter The <code>ActionMapping</code> parameter's name
        *
        * @return The method's name.
  +     * @since Struts 1.2.1
        */
       protected String getMethodName(ActionMapping mapping,
                                      ActionForm form,
  
  
  
  1.14      +19 -14    
jakarta-struts/src/share/org/apache/struts/actions/LookupDispatchAction.java
  
  Index: LookupDispatchAction.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-struts/src/share/org/apache/struts/actions/LookupDispatchAction.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LookupDispatchAction.java 13 Aug 2003 04:53:43 -0000      1.13
  +++ LookupDispatchAction.java 13 Aug 2003 05:29:27 -0000      1.14
  @@ -153,6 +153,7 @@
    * @author Scott Carlson
    * @author David Graham
    * @author Leonardo Quijano
  + * @author Rob Leland
    */
   public abstract class LookupDispatchAction extends DispatchAction {
   
  @@ -190,20 +191,23 @@
               throws Exception {
   
           if (isCancelled(request)) {
  -            return cancelled(mapping, form, request, response);
  -        } else {
  -            // 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);
  +            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);
  +        // Identify the string to lookup
  +        String methodName = getMethodName(mapping, form, request, response, 
parameter);
  +
  +        return dispatchMethod(mapping, form, request, response, methodName);
   
  -            return dispatchMethod(mapping, form, request, response, methodName);
  -        }
       }
   
       /**
  @@ -257,6 +261,7 @@
        * @param parameter The <code>ActionMapping</code> parameter's name
        *
        * @return The method's name.
  +     * @since Struts 1.2.1
        */
       protected String getMethodName(ActionMapping mapping,
                                      ActionForm form,
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to