WebObjects Builder recognizes three types of classes: base classes, such as numbers and strings, composite classes, such as arrays and dictionaries, and custom classes. You don't need to do anything special to create variables of a base class or an array class. But if you want to create a dictionary, you must first go to the Classes window and define the dictionary.
In this task, you will create a dictionary class named Guest. The Guest dictionary class has three keys: name, email, and comments. (You can think of this dictionary as a C structure with three fields.)
The application object browser appears. You use this browser to declare variables that have an application-wide scope. These variables are declared in the application script, which is an optional part of a WebObjects application.
This creates the application variable guests, which is an array of Guests.
You declared the guests array in the application script (which is named Application.wos) instead of the Main component's script. Why? So that it would exist for the life of the application. If you declared guests in the Main component (as you did the aGuest variable), guests would be created each time the Main page was redrawn. The Main page is redrawn every time a user clicks the Submit button, so guests would only ever contain one item - the last user who clicked submit.
Note: Component variables exist only as long as the component does, which is up until that component's page needs to be redrawn. Application variables (defined in Application.wos) live as long as the application does. There's a third type of variable, known as session variables. Session variables are declared in the session display of the application window and stored in the session script (Session.wos). They exist for the lifetime of one user's session. New session variables are created as new sessions are added. For example, if you declared a variable in Session.wos and three users were using the application, three instances of that variable would be created, one for each user. If the first user changed the value of that variable, the other two users would not see the change because the session variable is unique to each user's session.
You can read more about application variable, session variables, and component variables in "Using WebScript" in the WebObjects Developer's Guide.
Table of Contents Next Section