PATH |
Creating a WODisplayGroup
Description
Typically a WODisplayGroup has an EODatabaseDataSource, which in turn, has an EOEditingContext. The EODatabaseDataSource maintains a fetch specification and an array of objects obtained from the EOEditingContext. Figure 1 shows the relationship between the WODisplayGroup, its EODatabaseDataSource and the session's EOEditingContext.
The WODisplayGroup and its EODatabaseDataSource
You create most WODisplayGroups in one of these ways:
- By using Project Builder's wizard to build a component with the display group. Open your project in Project Builder. Click the Web Components suitcase and select File->New in Project. This builds a component containing a WODisplayGroup, an EODatabaseDataSource, and dynamic elements that display the WODisplayGroup's objects.
- By dragging an entity icon from the EOModeler application to a component opened in WebObjects Builder. This creates a WODisplayGroup and an EODatabaseDataSource.
In both cases, the EODatabaseDataSource is automatically created and attached to the session's default editing context.
Creating a Detail WODisplayGroup
Most WODisplayGroups operate independently of other WODisplayGroups; however, you can set up a master-detail association between two WODisplayGroups. You typically do this by dragging a to-many relationship from the EOModeler application to a component opened in the WebObjects Builder application. When you do this, the display group you create has an EODetailDataSource (defined in EOControl) as its data source, a detail key equal to the to-many relationship's key, and a master object equal to the entity from which you dragged the relationship. See "Setting Up a Master-Detail Configuration" in Getting Started With WebObjects .
Creating a WODisplayGroup Programmatically
To create a WODisplayGroup programmatically, you instantiate a EODatabaseDataSource and a WODisplayGroup. Then you make the proper connections between the EODatabaseDataSource, the WODisplayGroup, and the session's EOEditingContext. The following Java code, placed in a component's constructor, creates a WODisplayGroup and fetches all of the rows for the "Movie" entity.
public Main() { super(); EOEditingContext ec = this.session().defaultEditingContext(); EODatabaseDataSource ds = new EODatabaseDataSource(ec,"Movie"); moviesDisplayGroup = new WODisplayGroup(); moviesDisplayGroup.setDataSource(ds); moviesDisplayGroup.fetch();}
See Also
- Setting a WODisplayGroup's Fetch Specification Programmatically
- Using Master-Peer Configurations
- WODisplayGroup class specification in the WebObjects Framework Reference
- EODatabaseDataSource class specification in the Enterprise Objects Framework Reference
© 1999 Apple Computer, Inc.