I thought of that too but I don't know how to add parameters to the request.
Maybe you could use request.setAttribute and store the multi-part request
String parameters as attributes in the requet object. Then code that looks
for parameters could be changed to a method that looks for parameters or
attributes. I don't know if that would help matters much.

I use something similar in my application so that I can have an action that
is accessed from a link or from another action. In one case the paramters
are passed on the url and in the other case parameters are passed as request
attributes. The receiving action calls a method that checks for one and then
the other, using the first one it finds.

    protected String findStringParameter(HttpServletRequest request, String
key)
    {
        String value = request.getParameter(key);
        if (value == null)
        {
            value = (String) request.getAttribute(key);
        }
        return value;
    }

> -----Original Message-----
> From: SCHACHTER,MICHAEL (HP-NewJersey,ex2) [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 11, 2001 2:19 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE-2: cvs commit:
> jakarta-struts/src/share/org/apache/struts/acti on Action.java
> ActionForm.java
>
>
> On second thought, I'm going to toy around with putting the request
> parameters
> directly into the request from MultipartRequestHandler
> instead of using
> MultipartRequestHandler itself to store attributes.  If I can
> get it to work
> this will solve all
> the problems without adding any new methods to anything, or changing
> anything.
>
> -----Original Message-----
> From: SCHACHTER,MICHAEL (HP-NewJersey,ex2)
> Sent: Friday, May 11, 2001 2:08 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: cvs commit:
> jakarta-struts/src/share/org/apache/struts/action Action.java
> ActionForm.java
>
>
> Is this an acceptable resolution to this problem for
> everybody?  If so, I'll
> go ahead and fix the token problem in the Action class, be
> creating new
> isTokenValid() method that takes an HttpServletRequest and a
> MultipartRequestHandler
> as arguments, when using it for multipart forms.  The other
> token methods
> don't
> need to be changed, as they only deal with retrieiving
> session information.
>
> -----Original Message-----
> From: SCHACHTER,MICHAEL (HP-NewJersey,ex2) [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 11, 2001 1:29 PM
> To: '[EMAIL PROTECTED]'
> Subject: RE: cvs commit:
> jakarta-struts/src/share/org/apache/struts/action Action.java
> ActionForm.java
>
>
> Hal,
>
> It was my understanding that since isCancelled is a protected
> method in the
> Action class,
> that it was the Action developer's job to call the method.
>
> -----Original Message-----
> From: Deadman, Hal [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 11, 2001 1:24 PM
> To: [EMAIL PROTECTED]
> Subject: RE: cvs commit:
> jakarta-struts/src/share/org/apache/struts/action Action.java
> ActionForm.java
>
>
> Doesn't the Struts framework need to call this new method
> somewhere? The
> application code can't call the isCancelled method because
> the Action class
> code will never be called. If Struts ActionServlet calls the
> form validate
> when a user clicked cancel, the validation will likely fail
> and the user
> will be presented with the input form again. Clicking cancel
> needs to bypass
> the call to the form validate method. If that is done then the new
> isCancelled method may be used in the perform method.
>
> Hal
>
> > -----Original Message-----
> > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> > Sent: Friday, May 11, 2001 1:11 PM
> > To: [EMAIL PROTECTED]
> > Subject: cvs commit:
> jakarta-struts/src/share/org/apache/struts/action
> > Action.java ActionForm.java
> >
> >
> > mschachter    01/05/11 10:11:06
> >
> >   Modified:    doc      todo-1.1.xml
> >                src/share/org/apache/struts/action Action.java
> >                         ActionForm.java
> >   Log:
> >    - Add an isCancelled() method to the Action class that takes a
> >      MultipartRequestHandler as an argument.  This should address
> >      issues with the html:cancel tag, as long as the new isCancelled
> >      method is called on for multipart forms.
> >    - Add myself to the EJB Design Pattern TODO
> >
> >   Revision  Changes    Path
> >   1.3       +3 -0      jakarta-struts/doc/todo-1.1.xml
> >
> >   Index: todo-1.1.xml
> >
> ===================================================================
> >   RCS file: /home/cvs/jakarta-struts/doc/todo-1.1.xml,v
> >   retrieving revision 1.2
> >   retrieving revision 1.3
> >   diff -u -r1.2 -r1.3
> >   --- todo-1.1.xml  2001/04/12 16:00:42     1.2
> >   +++ todo-1.1.xml  2001/05/11 17:10:47     1.3
> >   @@ -159,6 +159,9 @@
> >          <assigned>
> >            <a href="mailto:[EMAIL PROTECTED]";>Nic Hobbs</a>
> >          </assigned>
> >   +      <assigned>
> >   +        <a href="mailto:[EMAIL PROTECTED]";>Mike Schachter</a>
> >   +      </assigned>
> >        </task>
> >
> >        <task name="HTML No-Cache Support">
> >
> >
> >
> >   1.20      +27 -4
> > jakarta-struts/src/share/org/apache/struts/action/Action.java
> >
> >   Index: Action.java
> >
> ===================================================================
> >   RCS file:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tion.java,v
> >   retrieving revision 1.19
> >   retrieving revision 1.20
> >   diff -u -r1.19 -r1.20
> >   --- Action.java   2001/02/23 21:13:09     1.19
> >   +++ Action.java   2001/05/11 17:10:55     1.20
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tion.java,v 1.19 2001/02/23 21:13:09 craigmcc Exp $
> >   - * $Revision: 1.19 $
> >   - * $Date: 2001/02/23 21:13:09 $
> >   + * $Header:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tion.java,v 1.20 2001/05/11 17:10:55 mschachter Exp $
> >   + * $Revision: 1.20 $
> >   + * $Date: 2001/05/11 17:10:55 $
> >     *
> >     *
> > ====================================================================
> >     *
> >   @@ -67,6 +67,7 @@
> >    import java.security.MessageDigest;
> >    import java.security.NoSuchAlgorithmException;
> >    import java.util.Locale;
> >   +import java.util.Hashtable;
> >    import javax.servlet.ServletException;
> >    import javax.servlet.ServletRequest;
> >    import javax.servlet.ServletResponse;
> >   @@ -75,6 +76,7 @@
> >    import javax.servlet.http.HttpSession;
> >    import org.apache.struts.taglib.html.Constants;
> >    import org.apache.struts.util.MessageResources;
> >   +import org.apache.struts.upload.MultipartRequestHandler;
> >
> >
> >    /**
> >   @@ -106,7 +108,7 @@
> >     * by this Action.
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.19 $ $Date: 2001/02/23 21:13:09 $
> >   + * @version $Revision: 1.20 $ $Date: 2001/05/11 17:10:55 $
> >     */
> >
> >    public class Action {
> >   @@ -466,6 +468,27 @@
> >     return
> > ((request.getParameter(Constants.CANCEL_PROPERTY) != null) ||
> >
> > (request.getParameter(Constants.CANCEL_PROPERTY_X) != null));
> >
> >   +    }
> >   +
> >   +    /**
> >   +     * Returns <code>true</code> if the current multipart
> > form's cancel button was
> >   +     * pressed.  This method will check if the cancel
> > button generated by
> >   +     * <strong>CancelTag</strong> was pressed by the user in the
> >   +     * current request.  If true, validation performed by an
> >   +     * <strong>ActionForm</strong> validate() method
> will have been
> >   +     * skipped by the controller servlet.  A
> > MultipartRequestHandler instance
> >   +     * can be obtained from a multipart form by calling
> >   +     * {@link ActionForm#getMultipartRequestHandler()
> > ActionForm.getMultipartRequestHandler()}.
> >   +     *
> >   +     * @param request The servlet request we are processing
> >   +     * @see org.apache.struts.taglib.CancelTag
> >   +     * @see org.apache.struts.action.ValidatingActionForm
> >   +     */
> >   +    protected boolean isCancelled(MultipartRequestHandler
> > request) {
> >   +
> >   +        Hashtable elements = request.getTextElements();
> >   +        return ((elements.get(Constants.CANCEL_PROPERTY)
> > != null) ||
> >   +                (elements.get(Constants.CANCEL_PROPERTY_X)
> > != null));
> >        }
> >
> >
> >
> >
> >
> >   1.7       +7 -5
> > jakarta-struts/src/share/org/apache/struts/action/ActionForm.java
> >
> >   Index: ActionForm.java
> >
> ===================================================================
> >   RCS file:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tionForm.java,v
> >   retrieving revision 1.6
> >   retrieving revision 1.7
> >   diff -u -r1.6 -r1.7
> >   --- ActionForm.java       2001/02/21 00:35:43     1.6
> >   +++ ActionForm.java       2001/05/11 17:10:58     1.7
> >   @@ -1,7 +1,7 @@
> >    /*
> >   - * $Header:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tionForm.java,v 1.6 2001/02/21 00:35:43 craigmcc Exp $
> >   - * $Revision: 1.6 $
> >   - * $Date: 2001/02/21 00:35:43 $
> >   + * $Header:
> > /home/cvs/jakarta-struts/src/share/org/apache/struts/action/Ac
> > tionForm.java,v 1.7 2001/05/11 17:10:58 mschachter Exp $
> >   + * $Revision: 1.7 $
> >   + * $Date: 2001/05/11 17:10:58 $
> >     *
> >     *
> > ====================================================================
> >     *
> >   @@ -94,7 +94,7 @@
> >     * </p>
> >     *
> >     * @author Craig R. McClanahan
> >   - * @version $Revision: 1.6 $ $Date: 2001/02/21 00:35:43 $
> >   + * @version $Revision: 1.7 $ $Date: 2001/05/11 17:10:58 $
> >     */
> >
> >    public abstract class ActionForm implements Serializable {
> >   @@ -134,7 +134,9 @@
> >         * The reasoning behind this is to give form bean developers
> >         * control over the lifecycle of their multipart requests
> >         * through the use of the finish() and/or rollback() methods
> >   -     * of MultipartRequestHandler
> >   +     * of MultipartRequestHandler.  This method will return
> >   +     * <code>null</code> if this form's enctype is not
> >   +     * "multipart/request-data".
> >         * @see org.apache.struts.upload.MultipartRequestHandler
> >         */
> >        public MultipartRequestHandler getMultipartRequestHandler() {
> >
> >
> >
> >
>

Reply via email to