Table of Contents Previous Section

Invoking an Action

In the second phase of the request-response loop, the application sends the invokeActionForRequest:inContext: message to itself, and eventually to all other objects involved in handling this request. The purpose of this message is to locate the dynamic element which the user has clicked (or otherwise activated) and have that element trigger the appropriate action method in the request component. This method returns the response page---the component responsible for generating an HTTP response. If the user has not triggered an action, the request component is used as the response component.

This is the basic sequence of events in invoking an action:

  1. The WOApplication object sends invokeActionForRequest:inContext: to itself; its implementation simply invokes the WOSession object's invokeActionForRequest:inContext:.

  2. The session, in its implementation of invokeActionForRequest:inContext:, gets the template of the component and forwards the message to it.

  3. Suitable dynamic elements in the request-page template, and in subcomponent templates, handle the invokeActionForRequest:inContext: message. To be suitable, an element must be able to respond to user actions (a WOSubmitButton or a WOActiveImage, for example). Each of these elements evaluates the invoked action to determine if it "owns" it. If so, it invokes the appropriate action method in the request page, which returns the response page.

For more on how components are associated with templates, and on how HTML elements participate in request-handling, see the section "Component and Element."



Figure 4: Invoking an Action

Table of Contents Next Section