To design the Main page, you'll use the WebObjects Builder Database Wizard. The Database Wizard performs all the setup that's necessary to fetch database records and display them in a web page. Specifying different wizard options yields completely different pages. For example, both the Browse Movies and Movie Search pages are designed with the Database Wizard.
Recall that you must create the application in a directory that's under DocumentRoot/WebObjects.
A Choose Database Adaptor panel opens.
An adaptor is a mechanism that connects your application to a particular database server. For each type of server you use, you need a separate adaptor. WebObjects provides adaptors for Informix, Oracle, and Sybase servers, and for any server that is ODBC compliant.
Note: Not all adaptors are available with all versions of WebObjects.
A login panel for the database that corresponds to the selected adaptor opens. The examples in this chapter use the Oracle version of the Movies database included with WebObjects.
When you use the Database Wizard to create a model file, the wizard uses a database adaptor to read the data dictionary from the database you specified in the login panel and to create a default model.
When you choose the Movie entity, the wizard displays its attributes. An attribute is a part of the database-to-object mapping that associates a database column with one of a class's instance variables. For example, the title attribute in the Movie entity maps the TITLE column of the MOVIE table to the title instance variable of Movie objects.
Enterprise Objects Framework uses primary keys to uniquely identify enterprise objects and to map them to the appropriate database row. Therefore, you must assign a primary key to each entity you use in your application. The Database Wizard sets the Movie entity's primary key to the attribute you choose; however, you'll need to explicitly assign primary keys to the other entities later on.
You should choose primary key attributes that are assigned initial values and then are never modified. Consequently applications usually assign primary key values automatically. For example, the Movies application assigns a movieId value to a new movie when it's created, and the value never changes afterward. The Movies interface doesn't even display movieId values because they aren't meaningful to users of the application.
Enterprise Objects Framework provides several mechanisms for generating and assigning unique values to primary key attributes. By default, Enterprise Objects Framework uses a native database mechanism to assign primary key values. The scripts that come with WebObjects for installing the Movies database set up the database for the default mechanism. See the chapter "Answers to Common Design Questions" in the Enterprise Objects Framework Developer's Guide for more information.
The order in which you add the attributes determines the order in which they appear on the page, so add them in the following order: title, category, rating, dateReleased, and revenue.
Don't add any of the remaining attributes. The language, movieId, and studioId attributes don't have meaning to users, and should not be displayed in the page.
Almost all of the page's dynamic elements are bound to methods in the movies variable. This variable is a WODisplayGroup. WODisplayGroups (also referred to as display groups) provide a simple interface for interacting with relational databases in terms of objects. A display group manages objects associated with a single entity. The movies display group operates on Movie objects because you chose the Movie entity when you ran the wizard.
Later in this tutorial, you'll build a page by hand that contains some of the same features as this Main page. At that time, you'll learn more about what the display group can do.
Table of Contents Next Section