You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Sridhar H C <Sr...@PLANETASIA.COM> on 2001/05/13 07:56:59 UTC
UN-subscribe me please
> -----Original Message-----
> From: William Shulman [SMTP:will@metaconsortium.com]
> Sent: Saturday, May 12, 2001 3:18 AM
> To: struts-dev@jakarta.apache.org
> Subject: RE: RE-2: cvs commit:
> jakarta-struts/src/share/org/apache/struts/acti on Action.java
> ActionForm.java
>
>
> Sounds like another good solution might be to implement a parameter
> stack in the request object. The parameter stack is a stack of
> Dictionary objects. When parameters are introduced, they are placed
> in the Dictionary on the top of the stack. Similarly for lookup. Stack
> frames (i.e. the Dictionaries) are pushed and popped appropriately as
> you chain.
>
> Just a thought. There may be some details to work out, but the
> solution would be very general and useful in many places.
>
> -will
>
> Martin Cooper writes:
> > As far as I am aware, you cannot add parameters to the request.
> >
> > I think storing values as request attributes and then looking there for
>
> > parameter values would be very dangerous. You could potentially break
> > existing code that uses request attributes to store data for chaining
> actions.
> >
> > Incidentally, Hal, I faced a similar problem in chaining actions. What
> I
> > did was to instantiate a separate form bean and store the chaining
> > parameters in that, then use one well-known (between our Actions, I
> mean)
> > request attribute to store that bean. The chained-to action checks for
> that
> > bean first, otherwise it uses the one Struts passed to the perform()
> method.
> >
> > --
> > Martin Cooper
> >
> >
> > At 12:38 PM 5/11/01, Deadman, Hal wrote:
> > >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:mschachter@hp.com]
> > > > Sent: Friday, May 11, 2001 2:19 PM
> > > > To: 'struts-dev@jakarta.apache.org'
> > > > 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: 'struts-dev@jakarta.apache.org'
> > > > 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:mschachter@hp.com]
> > > > Sent: Friday, May 11, 2001 1:29 PM
> > > > To: 'struts-dev@jakarta.apache.org'
> > > > 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:hal.deadman@tallan.com]
> > > > Sent: Friday, May 11, 2001 1:24 PM
> > > > To: struts-dev@jakarta.apache.org
> > > > 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: mschachter@apache.org [mailto:mschachter@apache.org]
> > > > > Sent: Friday, May 11, 2001 1:11 PM
> > > > > To: jakarta-struts-cvs@apache.org
> > > > > 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:nic.hobbs@uk.pwcglobal.com">Nic
> Hobbs</a>
> > > > > </assigned>
> > > > > + <assigned>
> > > > > + <a href="mailto:mschachter@hp.com">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() {
> > > > >
> > > > >
> > > > >
> > > > >
> > > >
> >
> >