struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Germuska <...@Germuska.com>
Subject multipart requests in struts-chain
Date Sat, 31 Jan 2004 22:30:20 GMT
It seems that struts-chain's AbstractPopulateActionForm was 
implemented with its own strategy for moving values from the context 
to the form.  Unfortunately, this strategy doesn't support multipart 
forms (file uploads).

I've hacked to make it work, but I thought I should understand the 
design decisions before committing any changes.  Or rather, let me 
explain how I fixed it -- trying to fit within the existing design -- 
and see if anyone (Craig?) has feedback.

I refactored the "execute" method of AbstractPopulateActionForm to this:

         ActionForm actionForm = ...
         if (actionForm == null) {
             return (false);
         }

         ActionConfig actionConfig = ...

         reset(context, actionConfig, actionForm);
         populate(context, actionConfig, actionForm);
         handleCancel(context, actionConfig, actionForm);

         return (false);

I moved the behavior which was there before into the two protected 
methods, "populate" and "handleCancel".  Then, in 
...servlet.PopulateActionForm, I overrode populate() to extract the 
suffix and prefix and call RequestUtils.populate(Object, prefix, 
suffix, request), which does handle file uploads.

I'm assuming the goal was to keep HttpServletRequest out of the base 
implementation.  Therefore, I'm assuming that these changes are in 
line with the design goals.  But I'd like a nod before I commit them.

The extraction of "handleCancel" was just to make the base "execute" 
read more clearly, and that method is not overridden in 
...servlet.PopulateActionForm.

Thanks
	Joe

-- 
Joe Germuska
Joe@Germuska.com
http://blog.germuska.com
       "Imagine if every Thursday your shoes exploded if you tied them 
the usual way.  This happens to us all the time with computers, and 
nobody thinks of complaining."
             -- Jef Raskin

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


Mime
View raw message