[Opensource] bug with transition (and parameter) handling in controllers with session scope form beans and forms with file inputs

Mike Traum mtraum at cirnetwork.org
Wed Feb 5 07:52:59 PST 2003


I think the critical code is at Controller.perform() (sorry I can't give you
a line number, I'm still working off of 5.01):
----------------------------------------------------------------------------
----
			if (form != null) {
				MultipartRequestHandler mp =
form.getMultipartRequestHandler();


				if (mp != null) {
----------------------------------------------------------------------------
----
It determines if the request should be using the multipart handler by
testing to see if one exists in the form. If we replace the 'mp != null'
test with a test on 'request.getContentType()', that should do it.

Here's the output I get from request.getContentType():
On a mutilpart form:
(java.lang.String) multipart/form-data;
boundary=---------------------------7d31843530688
On a 'regular' form:
(java.lang.String) application/x-www-form-urlencoded

So, I believe the code should be:
-------------------Orginial Code-----------------------------------------
				if (mp != null) {
					if (log.isDebugEnabled()) {
						log.debug("Multipart
request");
					}


					multiPart = true;
					req =
ServletControllerRequest.parseParamsMultiPart(mp,
							request,
							response,
							this);
	
req.setCallingServlet(mapping.getMappings().getServlet());
				}
-------------------Orginial Code-----------------------------------------
-------------------New Code----------------------------------------------
				if
(request.getContentType().startsWith("multipart/form-data")) {
					if (log.isDebugEnabled()) {
						log.debug("Multipart
request");
					}


					multiPart = true;
					req =
ServletControllerRequest.parseParamsMultiPart(mp,
							request,
							response,
							this);
	
req.setCallingServlet(mapping.getMappings().getServlet());
				}
				else {
	
form.setMultipartRequestHandler(null);
				}
-------------------New Code----------------------------------------------

Sorry, I can't implement this in the new code base until I clean up my
current project and migrate to the new codebase. Can someone do it for me?

thanks,
mike

-----Original Message-----
From: Michael Rimov [mailto:rimovm at centercomp.com]
Sent: Wednesday, February 05, 2003 1:32 AM
To: opensource at jcorporate.com
Subject: Re: [Opensource] bug with transition (and parameter) handling
in controllers with session scope form beans and forms with file inputs


Hi Mike,

At 06:27 PM 2/4/2003 -0600, you wrote:
>I've found a bug when you're using a controller containing with session 
>scope form beans.
>
>Here's the situation:
>1. A multipart form (form with a file upload) is submitted
>2. You transition to another state
>3. You attempt to transition to a third state, but it keeps transitioning 
>back to the same state
>
>This happens because submitting a multipart form sets 
>multipartRequestHandler on the form bean. If the multipartRequestHandler 
>of the form bean is set, the regular http parameters will be ignored. 
>Unfortunately, the multipartRequestHandler is never reset, so when you try 
>to transition to the 3rd state, it's reading the old parameter information 
>from the first submission.
>
>
>The Workaround:
>Add setMultipartRequestHandler(null) to the reset method of your form bean.
>

Any workarounds in Transition.transition() that we can put in the Expresso 
code base to help others out in need?

                                                 -Mike


_______________________________________________
Opensource mailing list
Opensource at jcorporate.com
http://mail.jcorporate.com/mailman/listinfo/opensource
Archives: http://mail.jcorporate.com/pipermail/opensource/



More information about the Opensource mailing list