

Configuring the Browser
In a way similar to the way you create bindings for a repetition, create your browser's bindings.- Bind talentDisplayGroup.displayedObjects to the browser's list attribute.
- Bind talent to the browser's item attribute.
- Bind talent.lastName to the browser's value attribute.
The value attribute tells the browser what string to display. For each item in its list, the browser evaluates the item's value.
- Add the method talentSelection to the MovieDetails.java class as follows:
public ImmutableVector talentSelection () { EnterpriseObject aTalent; EnterpriseObject aMovieRole = (EnterpriseObject)movieRoleDisplayGroup.selectedObject(); if (aMovieRole == null) { return null; } aTalent = (EnterpriseObject)aMovieRole.valueForKey("talent"); if (aTalent == null) { return null; } else { EnterpriseObject talentArray[] = {aTalent}; return new ImmutableVector(talentArray); } }
Because the browser expects a vector for its selections attribute, this method packages the selected MovieRole's talent object in a vector. If the selected MovieRole object is null, talentSelection simply returns null to indicate that the browser shouldn't set a selection.
- Add the method setTalentSelection as follows:
public void setTalentSelection(ImmutableVector talentVector) { if (talentVector.size() > 0) { EnterpriseObject aMovieRole = (EnterpriseObject)movieRoleDisplayGroup.selectedObject(); EnterpriseObject selectedTalent = (EnterpriseObject)talentVector.firstElement(); aMovieRole.addObjectToBothSidesOfRelationshipWithKey( selectedTalent, "talent" ); } }
Again because the browser uses a vector for its selections attribute, the setTalentSelection method must take a vector as its argument. If talentVector's size is nonzero, then this method sets the selected MovieRole's talent to the first object in the vector. Note that by default, a user can't select more than one actor in a browser.
- Bind talentSelection to the browser's selections attribute.
Table of Contents
Next Section