Documentation Archive Developer
Search
Table of Contents Previous Section

Creating a Detail Display Group

You can create a detail display group several different ways. You can write a declaration for it in Project Builder, or you can use WebObjects Builder's Add Variable/Method command. But the easiest way to create a detail display group is by dragging a relationship from EOModeler into your component, as described below.

  1. In EOModeler's tree view, expand the Movie entity.

  2. Drag the Movie's movieRoles relationship from the tree view into the MovieDetails component's object browser.

    An Add Display Group panel opens.

  3. In the Add Display Group panel, change the name to movieRoleDisplayGroup (remove the "s" from "Roles").

  4. Click Add and Configure.

    The Display Group Options panel opens so you can immediately configure the newly created display group.

    Notice that the "Has detail data source" box is checked. This means that movieRoleDisplayGroup gets its objects from a DetailDataSource object.

    All display groups use some kind of data source to fetch their objects. A data source is an object that exists primarily as a simple means for a DisplayGroup to access a store of objects. It's through a data source that a display group fetches, inserts, updates, and deletes database records.

    A DetailDataSource is a subclass of DataSource that's intended for use in master-detail configurations. A detail data source keeps track of a master object and a detail key. The master object is typically the selected object in a master display group, but a master display group isn't strictly required. The detail key is the name of the relationship on which the master-detail configuration is based. When a detail display group asks its data source to fetch, the DetailDataSource simply gets the destination objects from the master object as follows:

    detailObjects = masterObject.valueForKey(detailKey);
    

    In your master-detail configuration, the master object is the selected Movie, and the detail key is movieRoles. When movieRoleDisplayGroup asks its data source for its MovieRole objects, the detail DisplayGroup returns the objects in the selected Movie's movieRoles vector of MovieRoles. Similarly, when MovieRole objects are inserted or deleted in movieRoleDisplayGroup, they are added and removed from the master object's movieRoles vector.

  5. Set the display group to sort alphabetically by roleName.

  6. Check the "Fetches on load" box.

    When "Fetches on load" is selected, the display group fetches its objects as soon as the component is loaded into the application. You want this feature in the MovieDetails page so that users are immediately presented with the selected movie's roles. In contrast, the Main page does not fetch on load; it shouldn't present a list of movies until the user has entered search criteria and clicked Match.

  7. Click OK.

  8. In Project Builder, modify MovieDetail's setSelectedMovie method to look like the following:
    public void setSelectedMovie(EnterpriseObject newSelectedMovie) {
        selectedMovie = newSelectedMovie;
    
        // Add this line.
        movieRoleDisplayGroup.setMasterObject(newSelectedMovie);
    }
    

    With this addition, whenever a user navigates to the MovieDetails page, setSelectedMovie updates the movieRoleDisplayGroup's master object so it displays the corresponding MovieRole objects.

Table of Contents Next Section