Taking Input Values From a Request
The takeValuesFromRequest:inContext: method is invoked during the first phase of the request-response loop, immediately after all of the objects involved in the request have performed their awake methods. When this phase concludes, the request component has been initialized with the bindings made in WebObjects Builder.Override takeValuesFromRequest:inContext: when you want to do one of the following:
- Access information from the request or context object.
- Perform postprocessing on user input.
// WebScript example - takeValuesFromRequest:request inContext:context { id userAgent = [request headerForKey:@"user-agent"]; [self recordUserAgent:userAgent]; [super takeValuesFromRequest:request inContext:context]; }The following example performs postprocessing. It takes the values for the street, city, state, and zipCode variables and stores them in the address variable formatted as a standard mailing address.
// WebScript example - takeValuesFromRequest:request inContext:context { [super takeValuesFromRequest:request inContext:context]; address = [NSString stringWithFormat:@"%@\n%@, %@ %@", street, city, state, zipCode]; } // Java example public void takeValuesFromRequest(Request request, Context context) { super.takeValuesFromRequest(request, context); address = street + city + state + zipCode; }
Table of Contents Next Section