PATH Documentation > WebObjects

Table of Contents

EOAssociation


Inherits from:
EODelayedObserver (EOControl) : Object
Implements:
NSDisposable
EOObserving (EOControl)
Package:
com.webobjects.eointerface

Class at a Glance


An EOAssociation maintains a two-way binding between the properties of a display object, such as a text field or combo box, and the properties of one or more enterprise objects contained in one or more EODisplayGroups. You typically create and configure associations in Interface Builder, using the programmatic interface only when you write your own EOAssociation subclasses.

Principal Attributes



Class Description


EOAssociation defines the mechanism that transfers values between EODisplayGroups and the user interface of an application. An EOAssociation instance is tied to a single display object, a user interface object or other kind of object that manages values intended for display. The EOAssociation takes over certain outlets of the display object and sets its value according to the selection in the EODisplayGroup. An EOAssociation also has various aspects, which define the different parameters of the display object that it controls, such as the value or values displayed and whether the display object is enabled or editable. Each aspect can be bound to an EODisplayGroup with a key denoting a property of the enterprise objects in the EODisplayGroup. The value or values of this property determine the value for the EOAssociation's aspect.

EOAssociation is an abstract class, defining only the general mechanism for binding display objects to EODisplayGroups. You always create instances of its various subclasses, which define behavior specific to different kinds of display objects. For information on the different EOAssociation subclasses you can use, see the following subclass specifications:


com.webobjects.eointerface.cocoa
EOCocoaButtonPlugin EOCocoaSimpleTextPlugin
EOCocoaCheckBoxPlugin EOCocoaTableColumnPlugin
EOCocoaComboBoxPlugin EOCocoaTableViewPlugin
EOCocoaImageViewPlugin EOCocoaTextFieldPlugin
EOCocoaPopUpButtonPlugin EOCocoaTextPlugin
EOCocoaRadioMatrixPlugin  


com.webobjects.eointerface.swing
EOSwingButtonPlugin EOSwingQuickTimeViewPlugin
EOSwingCheckBoxPlugin EOSwingTableColumnPlugin
EOSwingComboBoxPlugin EOSwingTablePlugin
EOSwingImageViewPlugin EOSwingTextPlugin
   

You normally set up EOAssociations using Interface Builder; each of the class specifications for EOAssociation's subclasses provide an example using Interface Builder to set them up. EOAssociation's programmatic interface is more important when defining custom EOAssociation subclasses. For more information on EOAssociations, see the sections:




Constants


EOAssociation defines the following String constants to identify the names of association aspects:


ActionAspect NullAspectSignature
ArgumentAspect ParentAspect
AttributeAspectSignature SelectedIndexAspect
AttributeToManyAspectSignature SelectedObjectAspect
AttributeToOneAspectSignature SelectedTitleAspect
AttributeToOneToManyAspectSignature SourceAspect
BackgroundColorAspect TextColorAspect
BoldAspect TitlesAspect
DestinationAspect ToManyAspectSignature
EnabledAspect ToOneAspectSignature
ItalicAspect ToOneToManyAspectSignature
MatchKey1Aspect URLAspect
MatchKey2Aspect ValueAspect
MatchKey3Aspect  



Interfaces Implemented


NSDisposable
dispose
EOObserving


Method Types


All methods
EOAssociation
associationClassesForObject
registerAssociationClass
aspectSignatures
aspects
bindAspect
breakConnection
copyMatchingBindingsFromAssociation
displayGroupForAspect
displayGroupKeyForAspect
endEditing
establishConnection
isConnected
isEnabled
isEnabledAtIndex
isExplicitlyDisabled
isUsableWithObject
object
objectKeysTaken
primaryAspect
priority
setExplicitlyDisabled
setObject
setValueForAspect
setValueForAspectAtIndex
shouldEndEditing
shouldEndEditingAtIndex
subjectChanged
valueForAspect
valueForAspectAtIndex


Constructors



EOAssociation

public EOAssociation(Object anObject)

Description forthcoming.


Static Methods



associationClassesForObject

public static NSArray associationClassesForObject(Object anObject)

Description forthcoming.

registerAssociationClass

public static void registerAssociationClass(Class aClass)

Description forthcoming.


Instance Methods



aspectSignatures

public NSArray aspectSignatures()

Overridden by subclasses to return the signatures of the receiver's aspects, an array of string objects matching its aspects array index for index. The signature strings can be any of:
Constant The Aspect Can Be Bound to
AttributeAspectSignature Attributes
AttributeToOneAspectSignature Attributes and to-one relationships
AttributeToManyAspectSignature Attributes and to-many relationships
AttributeToOneToManyAspectSignature Attributes, to-one relationships, and to-many relationships
ToOneAspectSignature To-one relationships
ToOneToManyAspectSignature To-one and to-many relationships
ToManyAspectSignature To-many relationships
NullAspectSignature An EODisplayGroup without a key (the key is irrelevant).

Interface Builder uses aspect signatures to enable and disable keys in its Connections inspectors.

EOAssociation's implementation of this method returns an array of AttributeToOneToManyAspectSignature strings.



aspects

public NSArray aspects()

Overridden by subclasses to return the names of the receiving class's aspects as an array of string objects. Subclasses should include their superclass's aspects and add their own when overriding this method.

bindAspect

public void bindAspect( String aspectName, EODisplayGroup anEODisplayGroup, String key )

Defines the receiver's link between its display object and aEODisplayGroup. aspectName 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. See "Setting up an EOAssociation Programmatically" (page 43) in the class description for more information.

breakConnection

public void breakConnection()

Removes the receiver from its EODisplayGroup and display object. Subclasses should override this method to remove the receiver from any outlets of the display object and invoke super's implementation at the end.

See Also: establishConnection



copyMatchingBindingsFromAssociation

public void copyMatchingBindingsFromAssociation(EOAssociation anEOAssociation)

Description forthcoming.

displayGroupForAspect

public EODisplayGroup displayGroupForAspect(String aspectName)

Returns the EODisplayGroup bound to the receiver for aspectName, or null if there's no such object.

See Also: displayGroupKeyForAspect



displayGroupKeyForAspect

public String displayGroupKeyForAspect(String aspectName,)

Returns the EODisplayGroup key bound to the receiver for aspectName, or null if there's no EODisplayGroup.

See Also: displayGroupForAspect



dispose

public void dispose()

Description forthcoming.

endEditing

public boolean endEditing()

Overridden by subclasses to pass the value of the receiver's display object to the EODisplayGroup, by invoking setValueForAspect with the display object's value and the appropriate aspect (typically "value"). Returns true if successful, false if not-specifically if setValueForAspect returns false.

Subclasses whose display objects immediately pass their changes back to the EOAssociation-such as a button or pop-up list-need not override this method. It's only needed when the display object's value is edited rather than simply set.

EOAssociation's implementation does nothing but return true.



establishConnection

public void establishConnection()

Overridden by subclasses to attach the receiver to the outlets of its display object, and to otherwise configure the display object (such as by setting its action method). EOAssociation's implementation subscribes the receiver as an observer of its EODisplayGroups. Subclasses should invoke super's implementation after establishing their own connections.

See "Setting up an EOAssociation Programmatically" (page 43) in the class description for more information.



isConnected

public boolean isConnected()

Description forthcoming.

isEnabled

protected boolean isEnabled()

Returns false if the receiver has explicitly disabled its display object or if the receiver's EnabledAspect (if bound) resolves to false; true otherwise.

isEnabledAtIndex

protected boolean isEnabledAtIndex(int index)

Returns false if the receiver has explicitly disabled its display object or if the receiver's EnabledAspect (if bound) resolves to false for index; true otherwise.

isExplicitlyDisabled

public boolean isExplicitlyDisabled()

Returns true if the receiver has explicitly disabled its display object, false otherwise.

isUsableWithObject

public boolean isUsableWithObject(Object anObject)

Overridden by subclasses to return true if instances of the receiving class are usable with anObject false if they aren't. The receiving class can examine any relevant characteristic of anObject-its class, configuration (such as whether an NSMatrix operates in radio mode), and so on.

object

public Object object()

Description forthcoming.

objectKeysTaken

public NSArray objectKeysTaken()

Overridden by subclasses to return the names of display object outlets that instances assume control of. Interface Builder uses this information to disable connections from these outlets in its Connections Inspector.

primaryAspect

public String primaryAspect()

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.

priority

public int priority()

Returns the receiver's change notification priority. For more information, see the EODelayedObserver class specification (EOControl).

setExplicitlyDisabled

public void setExplicitlyDisabled(boolean flag)

Sets according to flag whether or not the association is explicitly disabled. An association is "explicitly disabled" when the display object shouldn't be editable, such as in the case where the display object simply displays the results of a search.

setObject

public void setObject(Object anObject)

Description forthcoming.

setValueForAspect

public boolean setValueForAspect( Object value, String aspectName)

Sets a value of the selected enterprise object in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a setSelectedObjectValue message with value and the key as arguments. Returns true if successful, or if there's no display group bound to aspectName. Returns false if there's an display group and it doesn't accept the new value.

See Also: valueForAspect



setValueForAspectAtIndex

public boolean setValueForAspectAtIndex( Object value, String aspectName, int index)

Sets a value of the enterprise object at index in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a setValueForObjectAtIndex message with value, index, and the key as arguments. Returns true if successful, or if there's no display group bound to aspectName. Returns false if there's a display group and it doesn't accept the new value.

See Also: valueForAspectAtIndex



shouldEndEditing

public boolean shouldEndEditing( String aspectName, String inputString, String errorDescription)

Invoked by subclasses when the display object fails to validate its input, this method informs the EODisplayGroup bound to aspectName with an associationFailedToValidateValue message, using the display group's selected object. Returns the result of that message, or true if there's no display group.

For example, an association bound to an NSControl object (Cocoa) receives a controlDidFailToFormatStringErrorDescription delegate message when the control's formatter fails to format the input string. Its implementation of that method invokes shouldEndEditing.



shouldEndEditingAtIndex

public boolean shouldEndEditingAtIndex( String aspectName, String inputString, String errorDescription, int index)

Works in the same manner as shouldEndEditing, but allows you to specify a particular object by index rather than implicitly specifying the selected object.

subjectChanged

public void subjectChanged()

Overridden by subclasses to update state based when an EODisplayGroup's selection or contents changes. This method is invoked automatically anytime a display group that's bound to the receiver changes. The receiver can query its display group with selectionChanged and contentsChanged messages to determine how it needs to update.

valueForAspect

public Object valueForAspect(String aspectName)

Returns a value of the selected enterprise object in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a selectedObjectValueForKey message with the key. Returns null if there's no display group or key bound to aspectName.

See Also: setValueForAspect



valueForAspectAtIndex

public Object valueForAspectAtIndex( String aspectName, int index)

Returns a value of the enterprise object at index in the EODisplayGroup bound to aspectName. Retrieves the display group and key bound to aspectName, and sends the display group a valueForObjectAtIndex message with index and the key. Returns null if there's no display group or key bound to aspectName.

See Also: valueForAspectAtIndex



© 2001 Apple Computer, Inc. (Last Published April 21, 2001)


Table of Contents