Action called twice for single form submission
Action called twice for single form submission
- Subject: Action called twice for single form submission
- From: Allen Cronce <email@hidden>
- Date: Sat, 3 Apr 2004 10:01:35 -0800
Hi all,
I and others have been talking about this on the Omni group list, so I
thought I'd post here too.
I spent several hours yesterday and today debugging an editing context
problem. It turns out that the problem is a side effect of the fact
that a WOSubmitButton action is unexpectedly being called twice. This
results in instancing a new page, rendering that page, then the action
is called again, instancing another copy.
Using an override of dispatchRequest in my Application, I've verified
that the browser is performing both a POST and a GET of the form
action. This does not seem to be a WebObjects bug.
So the for the following source:
<form method="post"
action="/cgi-bin/WebObjects/MyApp.woa/wo/JvsF931ATM5b1C7InWdNZw/
17.0.17.9">
<p style="text-align: center"><INPUT TYPE=SUBMIT NAME="Begin"
VALUE="Begin Process"></p>
</form>
Safari and IE Mac perform a POST of the action URL, calling my action
method, which constructs and renders the next page. Then after the page
is displayed, the browser performs a GET of the same action URL, which
constructs the page again (although the browser doesn't render it).
This happens to cause bad side effects in my application on certain
pages.
I admit that I'm not an HTTP expert and never written a browser, so I'm
a little unclear as to why Safari and IE are performing both a POST and
a GET. It certainly seems wrong to me. Incidentally, Mozilla does not
do this. It just does the post, as I would expect.
Fortunately there is a work around. When I change the form definition
in the wod file to explicitly specify a "get" method binding, Safari
does one (and thankfully only one ;-) get request. This should be OK
because in the pages where this is a problem, I'm just using the submit
button as a "Next" link, so there are no form values.
Does this seem like a reasonable work around, or is there a better,
more general solution? Should WO detect a GET following a POST for the
same URL and suppress it?
Best regards,
--
Allen Cronce
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.