form woes

Ondřej Čada <[email protected]> Sun, 19 Feb 2012 22:25:10 +0100
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Well, a few hours ago I've set up my first file uploading form in =
WONDER/WOLips/WO 5.4.3.

Incredible fun.

As soon as I've set up "multipart/form-data", I've stopped getting my =
action. That one was comparatively easy -- I just had to copy the action =
from the submit button binding to the form binding.

As soon as the action was fixed, it got couriouser and couriouser -- =
I've found I'm not getting any form data.

Overriding takeValuesFromRequest at all levels I've found that both =
application and session get the form all right, in other words, the =
ERXRequest's formValues does contain proper data there. Nevertheless, at =
the very beginning of component's takeValuesFromRequest the form gets =
weirdly re-interpreted -- formValues are empty; on the other hand, the =
ERXRequest body is nonempty now.

Spending some time googling I've found this happens when encodings are =
switched; nevertheless, I do not switch encodings at all. At the =
beginning I set =
ERXMessageEncoding.setDefaultEncodingForAllLanguages("UTF-8") and that's =
all.

Well I've overridden application's _createRequest, and using my own =
ERXRequest subclass I've intercepted methods to see what happens betw. =
session and first component takeValuesFromRequest. Far as I can say, =
nothing happens.

After trying lots and lots of things, I've eventually stuck with this =
class (whose instance is returned from ). It's rather ugly, but whatever =
I did, I did not find any other way to make it work :(

=3D=3D=3D
class WTFRequest extends ERXRequest {
	NSMutableDictionary savedFormValues;
	NSDictionary formValues() {
		NSDictionary d=3Dsuper.formValues();
		if (d?.count()=3D=3D0) {
			if (savedFormValues) return savedFormValues;
		} else {
			if (!savedFormValues)
				savedFormValues=3Dd.mutableClone();
			else =
savedFormValues.addEntriesFromDictionary(d);
		}
		return d;
	}
}
=3D=3D=3D

Now I am getting the form data, normal ones and WOFileUpload ones as =
well -- but for mimeType, that one comes in the form all right, but for =
whatever weird reason the binding does not fill the variable. Oh, well; =
I'm using file name suffix instead...

Sum it all, six-odd hours to implement something which used to take full =
six minutes in WOBuilder, Xcode and WO 5.3 and before :( I do wonder =
what's the culprit; this is sorta big mess to my liking :(

All the best,
---
Ondra =C4=8Cada
OCSoftware:     [email protected]               http://www.ocs.cz
private         [email protected]             http://www.ocs.cz/oc