Table of Contents Previous Section

Generating the Response

In the final phase of request-response loop, 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 to the total stream of HTML code that will be interpreted by the client browser.

This is the basic sequence of events in generating a response:

  1. The WOApplication object stores the object returned from an invoked action method as the current page for the transaction.

  2. Then it sends appendToResponse:inContext: to itself; its implementation simply invokes the WOSession object's appendToResponse:inContext:.

  3. The session, in its implementation of appendToResponse:inContext:, pushes the response component onto the WOContext stack, gets the template for the component, and sends appendToResponse:inContext: to the template.

  4. 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.

After the response has been generated, but before returning the response to the adaptor, the application object concludes request handling by doing the following:

  1. It causes the sleep method---the counterpart of awake---to be invoked in all components involved the transaction (request, response, and subcomponents). In sleep objects can release resources that don't have to be saved between transactions.

  2. Then the application requests the session object to save (cache) the response page.

  3. It invokes the session object's sleep method and saves the session object.

  4. It invokes its own sleep method.

When an object is about to be destroyed, its dealloc method is invoked. This happens some at some indefinite point after a transaction (indicated by vertical ellipses in the diagram below). In the dealloc method, the object should release any retained instance variable. (In scripted applications this is unnecessary since "garbage collection" occurs automatically in this case.)



Figure 5: Generating the Response
 

Table of Contents Next Section