Top

Creating a WebObjects Database Application


One of the most powerful features of WebObjects is its ability to provide access to databases. To do so, it uses a framework called the Enterprise Objects Framework. This chapter introduces you to the Enterprise Objects Framework by showing you how to create a simple database application. The steps you take in creating this application demonstrate the principles you'll use in every other application you develop with the WebObjects and Enterprise Objects Framework.

The application you'll create in this tutorial is called Movies. It makes use of a sample database, the Movies database, that contains information about movies. Before you do this tutorial, you need to set up the Movies database as described in the Post-Installation Instructions. In addition, if you aren't familiar with Project Builder and WebObjects Builder, read the first tutorials in this book, "Creating a Simple WebObjects Application" and "Enhancing Your Application", which introduce basic concepts and procedures you should know before you go on.

In this tutorial, you will:

Along the way, you'll learn basic Enterprise Objects Framework concepts you can use to design your own database applications.

The Movies Application

Enterprise Objects and the Movies Database
Enterprise Objects and Relationships

Designing the Main Page
Starting the WebObjects Application Wizard
Specifying a Model File
Choosing an Adaptor
Choosing What to Include in Your Model
Choosing the Tables to Include
Specifying Primary Keys
Specifying Referential Integrity Rules
Choosing an Entity
Choosing a Layout
Choosing Attributes to Display
Choosing an Attribute to Display as a Hyperlink
Choosing Attributes to Query On
Running Movies

Examining Your Project
Examining the Variables
Examining the Bindings
Bindings in the Query Part
Bindings in the Repetition Part
Bindings in the Editing Part

Refining Main.wo
Specifying a Sort Order
Specifying Default Values for New Enterprise Objects
Setting a Date Format
Setting a Number Format
Optional Exercise

Adding the MovieDetails Page
Creating the MovieDetails Component
Storing the Selected Movie
Navigating from Main to MovieDetails
Designing MovieDetails' User Interface
Adding Date and Number Formats
Navigating from MovieDetails to Main
Running Movies

Refining Your Model
Opening Your Model
Removing Primary and Foreign Keys as Class Properties
Adding Relationships to Your Model
Using the Advanced Relationship Inspector
Where Do Primary Keys Come From?

Setting Up a Master-Detail Configuration
Creating a Detail Display Group
Adding a Repetition
Configuring a Repetition
Running Movies

Updating Objects in the Detail Display Group
Managing a DisplayGroup's Selection
Adding a Form
Adding a Talent Display Group
Configuring the Browser
Adding Insert, Save, and Delete Buttons

Adding Behavior to Your Enterprise Objects
Specifying Custom Enterprise Object Classes
Generating Custom Enterprise Object Classes
Adding Custom Behavior to Talent
Providing Default Values in MovieRole
Running Movies

First Section