Ondřej Čada
2012-02-19 21:25:10 UTC
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 :(
===
class WTFRequest extends ERXRequest {
NSMutableDictionary savedFormValues;
NSDictionary formValues() {
NSDictionary d=super.formValues();
if (d?.count()==0) {
if (savedFormValues) return savedFormValues;
} else {
if (!savedFormValues)
savedFormValues=d.mutableClone();
else savedFormValues.addEntriesFromDictionary(d);
}
return d;
}
}
===
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 Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
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 :(
===
class WTFRequest extends ERXRequest {
NSMutableDictionary savedFormValues;
NSDictionary formValues() {
NSDictionary d=super.formValues();
if (d?.count()==0) {
if (savedFormValues) return savedFormValues;
} else {
if (!savedFormValues)
savedFormValues=d.mutableClone();
else savedFormValues.addEntriesFromDictionary(d);
}
return d;
}
}
===
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 Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc