Table of Contents Previous Section
Application Initialization
The application init method is invoked only once, when the application is launched. You perform two main tasks in the application's init method:
- Initialize application variables
- Configure applicationwide settings
// WebScript Application.wosThis method begins by calling the superclass's init method. Then, it initializes the application variable lastVisitor to be the empty string. (The application has just started, so there has been no last visitor.) Finally, it sets the default request handler to be the WODirectActionRequestHandler. WODirectActionRequestHandler handles requests for direct actions like the one shown in "Direct Actions". You set it to be the default request handler if you want to have initial requests go through the "defaultAction" of DirectAction.
- init {
self = [super init];
lastVisitor = @"";
[self setDefaultRequestHandler:
[self requestHandlerForKey:
[WOApplication directActionRequestHandlerKey]]];
return self;
} // Java Application.java
public Application () {
super();
...
lastVisitor = "";
setDefaultRequestHandler(requestHandlerForKey
(WOApplication.directActionRequestHandlerKey()));
...
}
You might want to do other configurations in the application object's init method as well. For example, you can control how pages and components are cached and how state is stored. For more information, read the chapter "Managing State".
Table of Contents Next Section