Re: weird combination! (followup: Form field ignored?!? Weird...)
Re: weird combination! (followup: Form field ignored?!? Weird...)
- Subject: Re: weird combination! (followup: Form field ignored?!? Weird...)
- From: Chuck Hill <email@hidden>
- Date: Thu, 25 Sep 2008 11:02:50 -0700
On Sep 25, 2008, at 8:24 AM, Ondřej Čada wrote:
Looks like I did find the culprit... kind of, but don't understand
it at all, to be frank :(
It seems that if the two following conditions are combined,
"multipart/form-data" forms send nulls only:
Close....
(a) storing session IDs into cookies, by
public class Session extends WOSession {
public Session() {
super();
setStoresIDsInCookies(true);
setStoresIDsInURLs(false);
}
}
(b) using UTF-8 as the page encoding, by
public class Application extends WOApplication {
...
// ensure UTF-8 is actually used anywhere
static public void updateResponseForUTF8(WOResponse rr) {
rr.setContentEncoding(_NSUtilities.UTF8StringEncoding);
Unless you are using 5.4.2 or 5.4.3 (can't recall which now, 5.4.3 I
think), _NSUtilities.UTF8StringEncoding returns the incorrect "UTF8"
string, no hyphen. This can cause the request to think that the
encoding has changed ( ! "UTF8".equals("UTF-8")) and it then discards
the form values. But with the "multipart/form-data" it then can't
recreate them so you get null. My bug notes say, "The hours this has
cost me..."
Try using rr.setContentEncoding("UTF-8");
rr.setHeader("text/html; charset=UTF-8; encoding=UTF-8",
"content-type");
}
public void appendToResponse(WOResponse rr, WOContext cc) {
updateResponseForUTF8(rr);
super.appendToResponse(rr,cc);
}
public void takeValuesFromRequest(WORequest rr, WOContext cc)
{ //!!!
rr.setDefaultFormValueEncoding(_NSUtilities.UTF8StringEncoding);
super.takeValuesFromRequest(rr,cc);
}
}
Actually the //!!! method is sufficient to render a multipart/form-
data" form not to work properly -- along with the IDs in cookies;
the appendToResponse method does not need to be overridden for the
problem to occur.
I would be grateful for an insight whether this is my bug or a WO
bug (should I perhaps ensure UTF-8 compliance otherwise?), and I
would be _very_ grateful for any advice how to solve the problem,
given the client insists on both session IDs in cookies and UTF8
pages...
If anyone cares to check, I am attaching the simple test project --
hope it will make it through the list software:
<WTF.zip>
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/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden