Generating the Response
In the final phase of request-response loop (see Figure 24), the response page generates an HTTP response. Generally, the response contains a dynamically generated HTML page. Each element (static and dynamic) that makes up the response page appends its HTML code to the total stream of HTML code that will be interpreted by the client browser.
- The application object stores the response component indicated by the action method's return value. (This action method was invoked during the second phase of the request-response loop.)
- If the response component is different from the request component, application sends the awake message to the response component.
- The application object sends appendToResponse:inContext: to itself; its implementation simply invokes the session object's appendToResponse:inContext: method.
- The session pushes the response component onto the WOContext stack and sends the response component the appendToResponse:inContext: message.
- The response component, in its implementation of appendToResponse:inContext:, gets the template for the component and sends appendToResponse:inContext: to the template's root object.
- All static and dynamic HTML elements in the response-page template, and in subcomponent templates, receive the appendToResponse:inContext: message. In it, they append to the content of the response the HTML code that represents them. For dynamic elements, this code includes the values assigned to variables.
- When control returns to the session object, the session object asks the WOStatisticsStore to record statistics about the response. WOStatisticsStore sends the session a descriptionForResponse:inContext: message. The session, in turn, sends the response component descriptionForResponse:inContext: message. By default, this method returns the response component's name.
- It causes the sleep method-the counterpart of awake-to be invoked in all components involved in the cycle (request, response, and subcomponents). As described in the chapter "Managing State", in the sleep method, objects can release resources that don't have to be saved between cycles.
- It requests the session object to save the response page in the page cache.
- It invokes the session object's sleep method.
- It saves the session object in the session store.
- It invokes its own sleep method.
Table of Contents Next Section