WebObjects/Web Applications/Development/How Forms Work< WebObjects
This document was written by Andrew Lindesay (http://www.lindesay.co.nz) and relates to WebObjects 5.3.
Component actions work by utilising the latter end of the action URL which will look something like 220.127.116.11 to allow the element which "owns" the action to invoke its bound action method. We call the inbound numerical string the "sender id" and the identifier of the element, the "element id". If the two match up then the element knows it should invoke its action.
If you have a form with many submit buttons this cannot be how the right action gets invoked because the action method contains a URL with a "sender id" of the form. This won't match with the "element id" of the submit button. For example, the following ficticious code illustrates this.
<form method="post" action="/cgi-bin/WebObjects/Foo.woa/1/wo/qtU2rRz2QrxNsJpxLRVqS0/0.32.0"> <input size="40" type="text" name="32.0.1"> <input type="submit" value="Search" name="32.0.2"> </form>
The submit button here might have element ID of 32.0.2, but the form has element 0.32.0. So it will not be possible to match up the sender id with the element id. So the question is; how does this mechanism work?
The submit button could look for a value of 32.0.2 in the inbound request. In this way it would be able to see the value Search and then invoke the bound action. However this mechanism is slightly more complex. The form element makes modifications to the context in order to get the submit buttons to exhibit this behaviour. Those modifications include setting the
setInForm(...) method as well as some internal methods to state if the form was submitted and if a submit button has invoked its action method yet.
If the submit button does invoke its method then it in turn modifies the context to state that an action had been "fired". If no submit button does set this value in the context then the form can invoke its own action method if appropriate.
Append To ResponseEdit
The WOForm simply sets into the context that it is in a form and then renders its children.
Take Values From RequestEdit
The WOForm sets into the context that the children are in a form and if the form was submitted and then allows its children elements to take their values from the request.