Apple WebObjects 3.5 Instrukcja Użytkownika Strona 115

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 120
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 114
Updating Objects in the Detail Display Group
115
Talent browser, the selection should refer to a single object.
Consequently, you need to add two methods to manage the browser’s
selection: one to return a vector containing the selected Talent and one
to set the selected Talent from a vector object.
4. 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.
5. 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"
);
}
}
Przeglądanie stron 114

Komentarze do niniejszej Instrukcji

Brak uwag