Table of Contents
Previous Section
The purpose of this first phase is to synchronize the state of the request component with the HTML page as submitted by the user. In this phase, the appropriate dynamic elements extract the values that users enter and the choices they make in the request page and assign them to declared variables. For example, if the user clicked a check box, the dynamic element that represents that check box must be set to the "checked" state. In other words, the checked attribute of the appropriate WOCheckbox dynamic element must be set to YES.
Note: The discussion of each phase includes a diagram that---using a matrix of object, relationship, and sequence---lays out the messages invoked and the tasks accomplished in the phase. The diagram is thus mean to accompany the discussion of these specific messages and tasks. The three diagrams, taken together, constitute a diagram of the entire request-response loop. The following diagram shows what goes on in the first phase:
Upon receiving handleRequest: from a WOAdaptor, the application first creates the WOResponse and WOContext objects that will be needed (the WORequest object is passed in). Then it does the following:
Each request received by a WebObjects application is associated with one of the application's pages---the request page. If the request doesn't explicitly specify a page, the WOApplication object associates the request with a page named "Main." By default, an application caches page instances once they're created, primarily to facilitate backtracking: when users backtrack, they're revisiting pages restored by the application. During the first phase of the request-response loop, the application restores the component instance that generated the response page earlier in the current session; if this instance doesn't exist, the application creates a component to represent the request page.
The component instance for the request page cannot be restored and must be created if:
This component---called the request component---is an instance of a WOComponent subclass (created automatically for scripted applications). The WOApplication object performs the following steps to create a WOComponent object:
When a component is created its init method is invoked. The awake method of both restored and created components is also invoked. In other words, the awake method of request components, as well as for the application and session objects, is invoked once per transaction. (There is one exception to this: When the response component is the same as the request component, awake is not invoked.)
During the first phase of the request-response loop, the request component extracts user-entered values and assigns them to transaction variables. This is the basic sequence of events in preparing for a request:
For more on how components are associated with templates, and on how HTML elements participate in request-handling, see "Component and Element."