

Adding Display Groups
A display group is an important type of variable that you use in WebObjects applications that access databases. A display group is an object that can fetch, insert, delete, display, update and search records in a database.This section describes the mechanics of adding display groups to a WebObjects project. For detailed information about display groups, see the DisplayGroup (Java) or WODisplayGroup (Objective-C) class specification in the WebObjects Class Reference. To learn more about how to create a WebObjects database application, see "Creating a WebObjects Database Application" in Getting Started With WebObjects.
In a database application, you use entity-relationship models. A model associates database columns with instance variables of objects. You create a model with the EOModeler application, or you can specify one when you use the Wizard to set up your application (when you add a model to your project, it is added to the Resources suitcase). A model is stored in a model file. For more information on creating models, see the chapter "Using EOModeler" in Enterprise Objects Framework Developer's Guide.
A model contains entities, attributes, and relationships. An entity associates a database table with an enterprise object class. Display groups manage objects associated with a single entity. An attribute associates a database column with an instance variable. A relationship is a link between two entities that's based on attributes of the entities.
If you used the Wizard to set up your application, a display group was set up for you based on the model you specified. There are several other ways to create a display group:
- Drag a model (a folder with the extension .eomodeld) from the file system into the object browser in your component window, or drag an entity from the EOModeler application into the object browser.
When you do this, a panel asks you if you want to add the model to your project. If you reply Yes, the Add Display Group panel appears.
It allows you to specify a name for your display group and decide if you want to simply add the display group, or configure it as well. "Configuring the Display Group" describes the configuration process.
- Use Add Variable/Method to define a variable of type DisplayGroup (Java) or WODisplayGroup (Objective-C or WebScript), or declare the display group directly in your code:
protected DisplayGroup myDisplayGroup; //this is a Java example
When you add a display group this way, you are responsible for making sure your project contains the appropriate model file. (For example, once a model file has been added, you can create any number of display groups based on it). In addition, you need to configure the display group.

In the figure, if you choose the entity CarPackage as the variable's type, the following code gets added to your source file:
/** @TypeInfo CarPackage */ protected EnterpriseObject myCarPackage;The variable myCarPackage is declared as type EnterpriseObject. The comment /** @TypeInfo CarPackage */ is a structured comment that WebObjects Builder uses to identify the entity associated with the object. It is then able to display the attributes in the object browser as shown here:

Table of Contents
Next Section