Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > Creating a Java Client Application: A Tutorial

   

Transferring Movies Between Studios

One of the primary functions of the StudioManager application is to allow one studio to purchase movies from another. To make this possible, you'll now add a pop-up list to the user interface.

The pop-up list displays a list of all of the studio titles. When you select a new studio in the pop-up list, you cause that studio to purchase the movie that's selected in the table view.

  1. Add a pop-up list.

    Drag a pop-up list (labeled "Item" on the Views palette) into the window.

    Control-drag from the pop-up list to the Studio EODisplayGroup.

    In the Inspector, select EOPopupAssoc from the pop-up list at the top of the left column.

    Select titles in the left column. The titles aspect is bound to the class key whose values you want to display in the pop-up list.

    Select name in the right column (since you want to display Studio names in the pop-up list).

    Put the pop-up list directly below the Studio table view and leave some space between it and the row of buttons. Later you will be adding fields between the pop-up list and the buttons. For a guide, see the figure associated with step 2, "Test your interface and try out the new pop-up list."

    Now you have to add another binding to the EOPopupAssociation so that when you change the selected studio title, it sets the corresponding studio relationship property in the selected Movie object.

    Control-drag from the pop-up list to the movies EODisplayGroup.

    In the Inspector, select EOPopupAssoc from the pop-up list at the top of the left column.

    Select selectedObject in the left column.

    Select studio in the right column.

    The selectedObject aspect is bound to the relationship property (in this example, Movie's studio property) that corresponds to the object bound to the titles aspect (Studio).

  2. Test your interface and try out the new pop-up list.

    Choose File Test Interface.

  3. Build and test-run the application.

    (See " Building and Testing Your Application " for details.)

    You can now test the behavior of the pop-up list. For example, suppose you want to transfer the movie "Alien" from the 20th Century Fox studio to MGM. First select 20th Century Fox to display its movies. Then select "Alien" in the list of movies. Finally, use the pop-up list to change the selected studio from 20th Century Fox to MGM. This has the effect of removing "Alien" from 20th Century Fox's movies relationship array and adding it to the movies relationship array of MGM. It also sets the "Alien" Movie object's studio relationship property to point to the new studio, MGM. When you use the pop-up list to transfer a movie, you'll notice that the movie disappears from the original studio's movie list and reappears in the movie list of the new studio.

    These changes aren't committed to the database until you click Save. At that time Enterprise Objects Framework translates the changes you made in the object graph into the appropriate database changes. For example, it sets the foreign key studioID in the transferred Movie object to have the same value as the studioID primary key of its new studio.

    Note that Enterprise Objects Framework manages all of this for you without requiring you to write any code.

    Related Concepts:   What is an Association?


© 1999 Apple Computer, Inc. – (Last Updated 13 Sep 99)