Request-handling methods – Apple WebObjects 3.5 User Manual

Page 50

Advertising
background image

Chapter 3

Common Methods

50

or

null

in Java). For more information, see the chapter “Managing State”

(page 109).

Request-Handling Methods

Request-handling is performed in three phases, which correspond to three
methods that you can override:

Taking input values from the request (

takeValuesFromRequest:inContext:

or

takeValuesFromRequest

)

Invoking the action (

invokeActionForRequest:inContext:

or

invokeAction

)

Generating a response (

appendToResponse:inContext:

or

appendToResponse

)

Each of the methods is implemented by WOApplication, WOSession, and
WOComponent. In each phase, WOApplication receives the message first, then
sends it to the WOSession, which sends it to the WOComponent, which sends
it to all of the dynamic element and component objects on the page.

The request-handling methods handle three types of objects:

A request object (WORequest or Request in Java) is passed as an argument
in the first two phases. This object represents a user request. You can use it
to retrieve information about the request, such as the method line, request
headers, the URL, and form values.

A context object (WOContext or Context in Java) is passed as an argument
in all three phases. This object represents the current context of the
application. It 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 application name, and the request page’s
name.

A response object (WOResponse in Java) is passed in the final phase. This
object encapsulates information contained in the generated HTTP
response, such as the status, response headers, and response content.

You should override these methods if you need to perform a task that requires
this type of information or you need access to objects before or after the action
method is invoked. For example, if you need to modify the header lines of an
HTTP response or substitute a page for the requested page, you would override

appendToResponse:inContext:

.

Advertising