Table of Contents
Previous Section
In a WebObjects application, pages aren't persistent. They're created at the beginning of a transaction, and they disappear at the end. A transaction is defined as a client request coming in and a response (usually an HTML page) going out. The life of a page actually spans two transactions:
Between these two occurrences, the WOWebScriptComponentController associated with a page is destroyed and reconstructed. Any variables in your component script that haven't explicitly been made persistent are lost.
For most variables, this automatic destruction isn't a problem. Either the variables' values don't need to be maintained or you can re-initialize them in your script's awake method. However, some variables need to live beyond the natural life cycle of a page. Such variables need to be declared as global, session, or persistent. This is discussed in more detail in the section "Variables and State."
When you declare a variable as global, it's maintained by the application across the life of the application. When you declare a variable as session or persistent, its state is restored when the application receives a request and stored before a response is returned.
Storing state is expensive. As users access an application and progress through its pages, the application accumulates state information for all active pages in what can be multiple sessions. This state can grow to be quite large. Consequently, you should use session and persistent variables only where necessary.