beautypg.com

Examining the variables, Examining the variables 80 – Apple WebObjects 3.5 User Manual

Page 80

background image

Chapter 3

Creating a WebObjects Database Application

80

Examining the Variables

1. Double-click

Main.wo

in Project Builder’s WebObjects Components category

to open the Main component in WebObjects Builder.

There are four variables in the object browser: the

application

and

session

variables that are available in all components and two others,

movie

and

movieDisplayGroup

.

The

movie

variable is an enterprise object that represents a row fetched from

the MOVIE table.

movieDisplayGroup

is a display group—an object that interacts

with a database, indirectly through classes in the Enterprise Objects
Framework. Display groups are used to fetch, insert, update, and delete
enterprise objects that are associated with a single entity.

movieDisplayGroup

’s

entity is Movie, which you specified in the wizard’s “Choose an entity”
page.

2. In Project Builder, look at the class file

Main.java

to see how

movie

is declared.

The

movie

declaration (shown below) declares

movie

to be an

EnterpriseObject—a Java interface that describes the general behavior that
all enterprise objects must have.

/** @TypeInfo Movie */ protected EnterpriseObject movie;

At run time,

movie

is a GenericRecord object. Recall that GenericRecord

is used to represent enterprise objects unless you specify a custom class.
Since you didn’t check the “Use custom enterprise objects” box in the
wizard’s “Choose what to include in your model” page, your application
defaults to using GenericRecord for all its entities.

The comment (

/** @TypeInfo Movie */

) is used by WebObjects

Builder to identify

movie

’s entity (Movie). Knowing the entity allows

WebObjects Builder to display

movie

’s attributes (

category

,

dateReleased

, and

so on). You can see

movie

’s attributes if you select the

movie

variable in the

WebObjects Builder’s object browser.

3. In Project Builder, examine

movieDisplayGroup

’s declaration in

Main.java

.

The declaration (shown below) declares

movieDisplayGroup

to be a

DisplayGroup.

protected DisplayGroup movieDisplayGroup;