Table of Contents Previous Section

takeValuesFromRequest:inContext:

This method is invoked during the phase of the request-response loop when the application stores user input. When this phase concludes, the request component has been initialized with the bindings made in WebObjects Builder or the assignments made in the declarations file.

The first argument to takeValuesFromRequest: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 references to information specific to the application, 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.

It is common to use this method to access request and context information. For example, the following implementation of takeValuesFromRequest:inContext: records the kinds of browsers---user agents---from which requests are made (the "recordUserAgent:" method is assumed to be implemented in the same script):

- takeValuesFromRequest:request inContext:context {
    id userAgent = [request headerForKey:@"user-agent"];
    [self recordUserAgent:userAgent]; 
    [super takeValuesFromRequest:request inContext:context];
}

When you invoke super's takeValuesFromRequest:inContext: in your implementation of the same method, the application processes user input. So after the message to super is when you could perform postprocessing of user input. For example, the following implementation takes the values for the street, city, state, and zipCode variables and stores them in address variable formatted as a standard mailing address.

- takeValuesFromRequest:request inContext:context {
    [super takeValuesFromRequest:request inContext:context];
    address = [NSString stringWithFormat:@"%@\n%@, %@  %@",
            street, city, state, zipCode];
}

Table of Contents Next Section