Discussion:
form woes
Ondřej Čada
2012-02-19 21:25:10 UTC
Permalink
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
Chuck Hill
2012-02-20 05:21:24 UTC
Permalink
Hi Ondřej,
Post by Ondřej Čada
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.
You are doing something wrong.
Post by Ondřej Čada
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.
Check the Properties file in ERXExtensions. There is a property that you set in your app that makes all the various places UTF-8. That is almost certainly your problem.
Post by Ondřej Čada
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 :(
If you are going to use Wonder. READ THAT PROPERTIES FILE. :-) It will make your life ever so much easier. "There is a property for that!" -- Wonder Logo
--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Ondřej Čada
2012-02-20 10:40:26 UTC
Permalink
Chuck,
Post by Chuck Hill
Check the Properties file in ERXExtensions. There is a property that you set in your app that makes all the various places UTF-8. That is almost certainly your problem.
Could well be, but are all those propertied documented anywhere? I've checked both the properties file generated from the WONDER/WO project template and http://wiki.wocommunity.org/display/WONDER/Explanation+of+the+default+properties+in+a+Wonder+project, and found nothing of encodings.
Post by Chuck Hill
You are doing something wrong.
Matter of fact, I fear there's a grave bug somewhere in between Eclipse/WOLips/Groovy, which makes things a bit stochastic :(

At the very least, I've just the very now noticed the incremental compiler (or code injector or something) _does_ do weird things. I've got this trivial action:

WOComponent removePic() {
market.marketBannerData=null
market.marketBannerMIME=null
return sess().saveChangesAction()
}

and wanted to check details, so I've simply added

WOComponent removePic() {
println "Wutthe... (${market.marketBannerMIME})"
market.marketBannerData=null
market.marketBannerMIME=null
return sess().saveChangesAction()
}

saved, let the incremental compiler/code injector do its magic, and clicked the hyperlink which is bound to the action again. The result looks like this (where "model.DBMarket" is the class of the "market" thing whilst "this" is a components.MarketEditor_):

groovy.lang.MissingPropertyException: No such property: sess for class: model.DBMarket
Possible solutions: class
[2012-2-20 10:47:18 CET] <WorkerThread11> groovy.lang.MissingPropertyException: No such property: sess for class: model.DBMarket
Possible solutions: class
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at components.MarketEditor_.removePic(MarketEditor_.groovy:56)

Something's right fishy there. Guess I'd rather wipe out all the stuff and re-install from scratch :(

Oh, sigh. Thanks a lot for all the advices!
---
Ondra Čada
OCSoftware: ***@ocs.cz http://www.ocs.cz
private ***@ocs.cz http://www.ocs.cz/oc
Chuck Hill
2012-02-21 00:45:59 UTC
Permalink
Post by Ondřej Čada
Chuck,
Post by Chuck Hill
Check the Properties file in ERXExtensions. There is a property that you set in your app that makes all the various places UTF-8. That is almost certainly your problem.
Could well be, but are all those propertied documented anywhere? I've checked both the properties file generated from the WONDER/WO project template and http://wiki.wocommunity.org/display/WONDER/Explanation+of+the+default+properties+in+a+Wonder+project, and found nothing of encodings.
I don't know. :-) I've always just looked at the Properties files in ERExtensions for the documentation and looked at the source if I needed further details.
Post by Ondřej Čada
Post by Chuck Hill
You are doing something wrong.
Matter of fact, I fear there's a grave bug somewhere in between Eclipse/WOLips/Groovy, which makes things a bit stochastic :(
Oh, I did not consider Groovy. Yes, that could be affecting things.
Post by Ondřej Čada
WOComponent removePic() {
market.marketBannerData=null
market.marketBannerMIME=null
return sess().saveChangesAction()
}
and wanted to check details, so I've simply added
WOComponent removePic() {
println "Wutthe... (${market.marketBannerMIME})"
market.marketBannerData=null
market.marketBannerMIME=null
return sess().saveChangesAction()
}
groovy.lang.MissingPropertyException: No such property: sess for class: model.DBMarket
Possible solutions: class
[2012-2-20 10:47:18 CET] <WorkerThread11> groovy.lang.MissingPropertyException: No such property: sess for class: model.DBMarket
Possible solutions: class
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
at org.codehaus.groovy.runtime.callsite.GetEffectivePogoPropertySite.getProperty(GetEffectivePogoPropertySite.java:86)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
at components.MarketEditor_.removePic(MarketEditor_.groovy:56)
Something's right fishy there. Guess I'd rather wipe out all the stuff and re-install from scratch :(
Oh, sigh. Thanks a lot for all the advices!
Sigh. Looks like you are in for some fun there. Good luck!


Chuck
--
Chuck Hill Senior Consultant / VP Development

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/gvc/practical_webobjects
Loading...