Table of Contents Previous Section

Application.wos

Application.wos is the application script for the Visitors application. It declares two global variables: visitorNum and lastVisitor. Global variables can be accessed throughout the application, and they live for the duration of the application. For more information on global variables, see the section "Variables and Scope."

id lastVisitor;    
  // the most recent visitor
id visitorNum;    
  // the total number of visitors the page
- awake {
  // Obsolete sessions that have been inactive for more than 2 minutes
   [WOApp setSessionTimeOut:120];
   visitorNum = 0; 
}

Using the awake Method

The Application.wos script includes a method called awake. In an application or component script, it's common to implement an awake method to prepare the associated page and its variables for use during the processing of the page.

For a given page, the awake method is invoked exactly once for each transaction. Therefore, if the same page handles the request as well as generates the response (for example, the first page of an application), the awake method is only invoked during the request phase.

The awake method is the best place to initialize variables whose values remain static for the life of the page, such as a list of hyperlinks. The advantage of using awake to perform this type of initialization is that the variables are guaranteed to be initialized every time the page is displayed.

Table of Contents Next Section