Table of Contents Previous Section Standard Methods You May Want to Implement

Standard Methods You May Want to Implement

Applications, sessions, and components define some common methods that you may want to implement. These methods are invoked during initialization, deallocation, and the request-response loop. (The request-response loop is a WebObjects application's main loop. It begins when the user generates a request by typing an URL or clicking a button on the page. It ends when the application has processed the request and generated a response page. One request-response loop cycle is called a transaction.) The list below provides a brief description of when you want to implement these methods.

Important: The chapter "Integrating Your Code Into the Request-Response Loop" in the WebObjects Developer's Guide provides full details on how to implement these methods. Read it before you write any code.

init
Initializes application variables, session variables, and any component variables that should persist as long as the component persists.

dealloc
Deallocates all variables initialized in the init method.

awake
Initializes variables that need to be reinitialized at the top of the request- response loop.

sleep
Sets to nil all variables that were initialized in the awake method.

takeValuesFromRequest:inContext:
Invoked at the beginning of the request-response loop, right after the awake method. Use this method to perform any tasks that need to be performed before the action of the page but after the bindings have been synchronized. (Bindings are synchronized by calling the superclass, WOComponent, implementation of ttakeValuesFromRequest:inContext: .)

invokeActionForRequest:inContext:
Invoked when the component is about to perform an action based on user input. Use this method if you want to generate a different object for the response page than would normally be created.

appendToResponse:inContext:
Invoked right after the request page has generated the response page. Use this method if you want to append text to the response page.


Table of Contents Next Section