WebObjects 5.2.3

com.webobjects.eointerface
Class EOValueSelectionAssociation

java.lang.Object
  extended bycom.webobjects.eocontrol.EODelayedObserver
      extended bycom.webobjects.eointerface.EOAssociation
          extended bycom.webobjects.eointerface.EOWidgetAssociation
              extended bycom.webobjects.eointerface.EOValueSelectionAssociation
All Implemented Interfaces:
EOObserving, NSDisposable

public class EOValueSelectionAssociation
extends EOWidgetAssociation

EOValueSelectionAssociation displays an attribute or to-one relationship value in a display object that offers the user multiple choices and the option of choosing just one of those choices. This association is typically used with pop-up lists, drop down menus, combo boxes, or radio matrices.

The value displayed in the display object can be set manually in Interface Builder or in the case of a relationship, constructed dynamically from values supplied by the destination entity's EODisplayGroup. The value displayed in the display object can be bound by one of three aspects: selectedTitle, which is useful for values representable as strings; selectedIndex, for integer values; and selectedObject, for the destination object of a relationship.

Usable with:
com.webobjects.eointerface.swing: javax.swing.JComboBox and its subclasses.
com.webobjects.eointerface.cocoa: NSComboBox, NSPopUpButton, NSRadioMatrix, and their subclasses.

Aspects:

titlesAn attribute of the objects in an EODisplayGroup whose values can be represented as strings.
selectedTitleAn attribute of the selected object whose values can be represented as strings.
selectedTagAn integer attribute of the selected object.
selectedObjectA to-one relationship of the selected object; the value displayed is that for the attribute bound to the titles aspect.
enabledA boolean attribute of the selected object, which determines whether the display object is enabled.

Examples:

There are several basic ways to configure, for example, a combo box and it's association. They are described below.
Selecting a String from a Static List

Suppose you have a Movie display group and you want to provide a pop-up list for setting the rating from a static list of strings. In this example, a Movie object's rating is a string property rather than a relationship to a Rating object. To do this, in Interface Builder, type the list of ratings into the pop-up list. Control-drag a connection from the pop-up list to the Movie display group. Choose EOValueSelectionAssociation in the Connections inspector, and bind the selectedTitle aspect to the "rating" key. With this configuration, if an object's string attribute value isn't in the pop-up list, it's temporarily added while the object is selected.

Selecting a String from a Dynamic List

This example is similar to the previous one, except in this example, a Movie object's rating is chosen from strings in a Rating database table. There's a Rating EODisplayGroup that fetches the ratings into Rating objects, and the pop-up list is filled from the "ratingString" property of the rating display group's Rating objects. To do this, in Interface Builder, Control-drag a connection from the pop-up list to the Ratings display group. Choose EOValueSelectionAssociation in the Connections inspector, and bind the titles aspect to the "ratingString" key. Similarly, Control-drag a connection from the pop-up list to the Movie display group. Again choose EOComboBoxAssociation in the Connections inspector, and bind the selectedTitle aspect to the "rating" key.

Selecting an Integer Tag from a Static List

Suppose you have a Customer enterprise object whose credit card type (Visa, MasterCard, and so on) is indicated by an integer tag. You want a user to be able to choose a customer's card type from a pop-up list. To do this, in Interface Builder, set the credit card names and tags for the pop-up list. Control-drag a connection from the pop-up list to the Customer display group. Choose EOValueSelectionAssociation in the Connections inspector, and bind the selectedTag aspect to the "cardType" key.

Selecting the Destination of a To-One Relationship

Suppose you have a list of employees and want to assign each employee a department. In terms of the object model, you want to assign a Department object as the destination of an Employee object's department relationship. To do this, in Interface Builder, Control-drag a connection from the pop-up list to a Department display group. Choose EOComboBoxAssociation in the Connections inspector, and bind the titles aspect to the "name" key. Similarly, Control-drag a connection from the pop-up list to the Employee display group. Again choose EOComboBoxAssociation in the Connections inspector, and bind the selectedObject to the "department" key. This fills the pop-up list with the names of departments, and causes the name of the selected Employee's Department to be selected in the pop-up list.


Nested Class Summary
static class EOValueSelectionAssociation.ValueSelectionPlugin
          ValueSelectionPlugin communicates with a UI widget on behalf of a EOValueSelectionAssociation.
 
Nested classes inherited from class com.webobjects.eointerface.EOWidgetAssociation
EOWidgetAssociation.WidgetPlugin
 
Field Summary
 
Fields inherited from class com.webobjects.eointerface.EOAssociation
ActionAspect, ArgumentAspect, AttributeAspectSignature, AttributeToManyAspectSignature, AttributeToOneAspectSignature, AttributeToOneToManyAspectSignature, BackgroundColorAspect, BoldAspect, ChildrenAspect, DestinationAspect, EnabledAspect, ExpandedIconAspect, IconAspect, IgnoreValue, IsLeafAspect, ItalicAspect, MatchKey1Aspect, MatchKey2Aspect, MatchKey3Aspect, NullAspectSignature, ParentAspect, RootAspect, SelectedIndexAspect, SelectedObjectAspect, SelectedTitleAspect, SetValue, SourceAspect, TextColorAspect, TitlesAspect, ToManyAspectSignature, ToOneAspectSignature, ToOneToManyAspectSignature, UnsetValue, URLAspect, ValueAspect
 
Fields inherited from class com.webobjects.eocontrol.EODelayedObserver
ObserverNumberOfPriorities, ObserverPriorityFifth, ObserverPriorityFirst, ObserverPriorityFourth, ObserverPriorityImmediate, ObserverPriorityLater, ObserverPrioritySecond, ObserverPrioritySixth, ObserverPriorityThird
 
Constructor Summary
EOValueSelectionAssociation(Object object)
          Creates a new EOValueSelectionAssociation to monitor and update the values in aDisplayObject.
 
Method Summary
 void bindAspect(String aspect, EODisplayGroup displayGroup, String key)
          Defines the receiver's link between its display object and displayGroup.
 boolean endEditing()
          See the endEditing method description in the superclass EOAssociation.
 String primaryAspect()
          Overridden by subclasses to return the default aspect, usually one denoting the displayed value, which by convention is named "value".
 void subjectChanged()
          See the subjectChanged method description in the superclass EOAssociation.
protected  Class widgetPluginClass()
          See the widgetPluginClass method description in the superclass EOWidgetAssociation.
 boolean widgetSelectionDidChange()
          Invoked by the association's plugin when the selection in the display object changes.
 
Methods inherited from class com.webobjects.eointerface.EOWidgetAssociation
canSupportValueFormatter, defaultPrefersContinuousChangeNotification, dispose, isUsableWithObject, objectKeysTaken, prefersContinuousChangeNotification, setDefaultPrefersContinuousChangeNotification, setObject, setPrefersContinuousChangeNotification, setValueFormatter, valueFormatter, widgetPlugin
 
Methods inherited from class com.webobjects.eointerface.EOAssociation
aspects, aspectSignatures, associationClassesForObject, breakConnection, copyMatchingBindingsFromAssociation, displayGroupForAspect, displayGroupKeyForAspect, establishConnection, isConnected, isEnabled, isEnabledAtIndex, isExplicitlyDisabled, object, priority, registerAssociationClass, setExplicitlyDisabled, setValueForAspect, setValueForAspectAtIndex, shouldEndEditing, shouldEndEditingAtIndex, valueForAspect, valueForAspectAtIndex
 
Methods inherited from class com.webobjects.eocontrol.EODelayedObserver
discardPendingNotification, objectWillChange, observerQueue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EOValueSelectionAssociation

public EOValueSelectionAssociation(Object object)
Creates a new EOValueSelectionAssociation to monitor and update the values in aDisplayObject.

You normally set up associations with the Interface Builder application, in which case you don't need to create them programmatically. However, if you do create them up programmatically, setting them up is a multi-step process. After creating an association, you must bind its aspects and establish its connections.

Parameters:
object - user interface widget for this association to connect to
Method Detail

bindAspect

public void bindAspect(String aspect,
                       EODisplayGroup displayGroup,
                       String key)
Defines the receiver's link between its display object and displayGroup. aspect is the name of the aspect it observes in its display object, and key is the name of the property it observes in aEODisplayGroup. Invoke establishConnection after this method to finish setting up the binding.

Overrides:
bindAspect in class EOAssociation
Parameters:
aspect - String that specifies what key of this association should be used to bind to EnterpriseObjects values
displayGroup - EODisplayGroup object to bind this association to
key - String specifying which property of the EOs in the display group should be used when setting values for aspect

endEditing

public boolean endEditing()
See the endEditing method description in the superclass EOAssociation. If ending editing fails, and the selected object aspect is bound, invokes associationFailedToValidateValue on the selected object display group.

Overrides:
endEditing in class EOAssociation
Returns:
true if editing in the display object ended successful, false if not

primaryAspect

public String primaryAspect()
Description copied from class: EOAssociation
Overridden by subclasses to return the default aspect, usually one denoting the displayed value, which by convention is named "value". EOAssociation's implementation returns null.

Overrides:
primaryAspect in class EOAssociation
Returns:
EOAssociaion.SelectedTitleAspect
See Also:
EOAssociation.primaryAspect()

subjectChanged

public void subjectChanged()
See the subjectChanged method description in the superclass EOAssociation.

Overrides:
subjectChanged in class EOAssociation
See Also:
EOAssociation.subjectChanged()

widgetPluginClass

protected Class widgetPluginClass()
See the widgetPluginClass method description in the superclass EOWidgetAssociation.

Overrides:
widgetPluginClass in class EOWidgetAssociation
Returns:
EOValueSelectionAssociation.ValueSelectionPlugin
See Also:
EOWidgetAssociation.widgetPluginClass()

widgetSelectionDidChange

public boolean widgetSelectionDidChange()
Invoked by the association's plugin when the selection in the display object changes.

Returns:
true if setting the new selection value in the display group succeeds, false otherwise

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.