Table of Contents Previous Section

willPrepareForRequest:inContext:

This method is invoked before the application stores user input. It is common to use this method to access request and context information. For example, the following implementation of willPrepareForRequest:inContext: records the kinds of browsers---user agents---from which requests are made:

- willPrepareForRequest:request inContext:context {
    id requestHeaders = [request headers];
    id userAgent = [requestHeaders objectForKey:@"user-agent"];
    [WOApp recordUserAgent:userAgent];
    return nil;
}

The first argument to willPrepareForRequest:inContext: is a WORequest object. A WORequest object encapsulates information from an HTTP request such as the method line, request headers, URL, and form values. The second argument is a WOContext object. A WOContext object contains application specific information such as the path to the request component's directory, the version of WebObjects that's running, the name of the application, and the name of the request page.

You can also use willPrepareForRequest:inContext: to substitute a different object for the request page. If this method returns a non-nil value, prepareForRequest: inContext: is sent to the substituted object. If you implement this method in the application and return a non-nil value, the substitute object will receive a willPrepareForRequest:inContext: message as well.

Table of Contents Next Section