PATH |
EOEntityController
Inherits from: EOComponentController : EOController : Object
Implements: EOObserving EOObjectDisplay EOAssociationConnector EOComponentController.EndEditing
Package: com.webobjects.eoapplication
Class Description
The EOEntityController class provides behavior for displaying enterprise objects in a user interface that can optionally be loaded from an archive (a nib file). EOEntityController's most basic API is specified by the interface EOObjectDisplay, which identifies an implementation strategy that uses EOEditingContexts and EODisplayGroups to manage an entity controller's enterprise objects. An entity controller has an entity name, which identifies the kind of enterprise objects the controller works with. Additionally it has an editing context that manages the controller's enterprise objects, a display group that displays the enterprise objects and manages a selection, and a controller display group that connects controller methods to the user interface. For more information, see the EOObjectDisplay interface specification.
User Interface Archive
As a subclass of EOComponentController, EOEntityController manages a user interface component. However, whereas component controllers dynamically generate their components, entity controllers have the ability to load their components from an archive. An entity controller has an archive name, which specifies the archive from which to load the controller's component. If, however, a controller doesn't have an archive name, the controller can fall back on dynamically generating its component (an empty EOView).
Managing the Editing Context
As mentioned earlier, EOEntityController uses an editing context to manage its enterprise objects. By default, an entity controller attempts to get its editing context from a supercontroller. An entity controller looks up the controller hierarchy for the first EOObjectDisplay ancestor that has an editing context. If it finds one, the entity controller uses that supercontroller's editing context. If it doesn't find one, it creates one.
You can change the way an entity controller gets its editing context by specifying a provider method with setEditingContextProviderMethodName. If an entity controller has an editing context provider method, it gets its editing context by invoking that method.
The provider method name is a string, which can be a key path or the name of an arbitrary class's static method. For an example of setting the method name to a key path, consider a subclass of EOEntityController that implements the method customizedEditingContext to return an editing context for the controller to use. In this case, the provider method name could be set to "customizedEditingContext".
If the provider method name is the name of a static method, the format of the string is "<class name>:<static method name>". For example, suppose that you've written a subclass of EOApplication that implements a static method, customizedEditingContextForAllControllers, to return an editing context for all an application's controllers to share. Then the editing context provider method name for all entity controllers could be set to "CustomApplicationClass:customizedEditingContextForAllControllers".
EOEntityController provides two methods that you can use as provider methods: newEditingContext and nestedEditingContext. The former simply creates a new editing context and is a convenience for setting the provider method. The latter attempts to create a new editing context that's nested inside an ancestor's editing context. If no ancestors provide an editing context to be a parent, nestedEditingContext simply creates a new editing context.
Managing the Display Group
EOEntityController uses a display group to display its enterprise objects. By default, an entity controller attempts to get its display group from a supercontroller. An entity controller looks up the controller hierarchy for the first EOObjectDisplay ancestor. If that supercontroller has the same entity name and a display group, the entity controller uses that supercontroller's display group. If it doesn't find one, it invokes loadArchive to see if a display group is provided in the archive. If the controller still doesn't have a display group, it simply creates one.
You can change the way an entity controller gets its display group by specifying a provider method with setDisplayGroupProviderMethodName. If an entity controller has a display group provider method, it gets its display group by invoking that method. The display group provider method name works the same way the editing context provider method name works. For more information, see "Managing the Editing Context" (page 182).
EOEntityController provides two methods that you can use as provider methods: newDisplayGroup and newDisplayGroupUsingOptimisticRefresh. The simply create new display groups and are convenience methods for setting the provider method.
Rule System and XML Description
The following tables identify the controllerType
, XML tag, and XML attributes used by the rule system and EOXMLUnarchiver to generate a controller hierarchy. For more information, see the section "Rule System and XML Description" (page 8) in the package introduction.
Default Rule System Controller Type |
entityController |
XML Tag |
ENTITYCONTROLLER |
XML Attribute | Value | Description |
archive |
string | The name of a nib file from which the controller loads its component (instead of dynamically creating it). |
displayGroupProviderMethodName |
string | A key path or string of the form "<class name>:<method name>" that names a method the controller uses to create its display group. |
editingContextProviderMethodName |
string | A key path or string of the form "<class name>:<method name>" that names a method the controller uses to create its editing context. |
entity |
string | Name of the controller's entity. |
Constants
Constant | Description |
NestedEditingContextProviderMethodName | Description forthcoming. |
NewDisplayGroupProviderMethodName | Description forthcoming. |
NewEditingContextProviderMethodName | Description forthcoming. |
Interfaces Implemented
EOObserving objectWillChange EOObjectDisplay controllerDisplayGroup displayGroup editingContext entityName EOAssociationConnector takeResposibilityForConnectionOfAssociation EOComponentController.EndEditing endEditing NSDisposable (Inherited from EOController) dispose EOKeyValueCodingAdditions (Inherited from EOController) EOAction.Enabling (Inherited from EOController) EOKeyValueCoding (Inherited from EOKeyValueCodingAdditions) NSKeyValueCoding (Inherited from EOKeyValueCoding)
Method Types
Constructors EOEntityController Setting the entity setEntityName Loading an archive prepareComponent loadArchive controllerDidLoadArchive objectForOutletPath setArchiveName archiveName Managing the editing context newEditingContext setEditingContext setEditingContextProviderMethodName editingContextProviderMethodName nestedEditingContext startListeningToEditingContext stopListeningToEditingContext handleEditingContextNotification setResetsEditingContextWhenPreparingForNewTask resetsEditingContextWhenPreparingForNewTask Managing the controller display group setControllerDisplayGroup hasControllerDisplayGroup Managing the objects display group newDataSource newDisplayGroup newDisplayGroupUsingOptimisticRefresh setDisplayGroup startListeningToDisplayGroup stopListeningToDisplayGroup setObjectWithGlobalID setObjectsWithFetchSpecification displayGroupSortOrderings setDisplayGroupProviderMethodName displayGroupProviderMethodName Accessing selected objects selectedObject selectedObjectGlobalID selectedObjects selectedObjectsGlobalIDs Fetching fetchesOnConnect setFetchesOnConnect Determining the root document controller isRootEntityController Notifying observers of change willChange Methods inherited from EOController connectionWasBroken connectionWasEstablished establishConnection prepareForNewTask Methods inherited from Object toString
Constructors
EOEntityController
public EOEntityController(EOXMLUnarchiver unarchiver)
public EOEntityController()
Instance Methods
archiveName
public String archiveName()
connectionWasBroken
protected void connectionWasBroken()
connectionWasEstablished
protected void connectionWasEstablished()
controllerDidLoadArchive
protected void controllerDidLoadArchive(NSDictionary aNSDictionary)
controllerDisplayGroup
public com.webobjects.eointerface.EODisplayGroup controllerDisplayGroup()
displayGroup
public com.webobjects.eointerface.EODisplayGroup displayGroup()
displayGroupProviderMethodName
public String displayGroupProviderMethodName()
displayGroupSortOrderings
protected NSArray displayGroupSortOrderings()
dispose
public void dispose()
editingContext
public com.webobjects.eocontrol.EOEditingContext editingContext()
editingContextProviderMethodName
public String editingContextProviderMethodName()
endEditing
public boolean endEditing()
entityName
public String entityName()
establishConnection
public void establishConnection()
fetchesOnConnect
public boolean fetchesOnConnect()
handleEditingContextNotification
public void handleEditingContextNotification(NSNotification aNSNotification)
hasControllerDisplayGroup
public boolean hasControllerDisplayGroup()
isRootEntityController
public boolean isRootEntityController()
loadArchive
protected boolean loadArchive()
nestedEditingContext
public com.webobjects.eocontrol.EOEditingContext nestedEditingContext()
newDataSource
protected com.webobjects.eocontrol.EODataSource newDataSource()
newDisplayGroup
public com.webobjects.eointerface.EODisplayGroup newDisplayGroup()
newDisplayGroupUsingOptimisticRefresh
public com.webobjects.eointerface.EODisplayGroup newDisplayGroupUsingOptimisticRefresh()
newEditingContext
public com.webobjects.eocontrol.EOEditingContext newEditingContext()
objectForOutletPath
public Object objectForOutletPath( EOArchive anEOArchive, String aString)
objectWillChange
public void objectWillChange(Object anObject)
prepareComponent
protected void prepareComponent()
prepareForNewTask
public void prepareForNewTask(boolean aBoolean)
resetsEditingContextWhenPreparingForNewTask
public boolean resetsEditingContextWhenPreparingForNewTask()
selectedObject
public com.webobjects.eocontrol.EOEnterpriseObject selectedObject()
selectedObjectGlobalID
public com.webobjects.eocontrol.EOGlobalID selectedObjectGlobalID()
selectedObjects
public NSArray selectedObjects()
selectedObjectsGlobalIDs
public NSArray selectedObjectsGlobalIDs()
setArchiveName
public void setArchiveName(String aString)
setControllerDisplayGroup
public void setControllerDisplayGroup(com.webobjects.eointerface.EODisplayGroup anEODisplayGroup)
setDisplayGroup
public void setDisplayGroup(com.webobjects.eointerface.EODisplayGroup anEODisplayGroup)
setDisplayGroupProviderMethodName
public void setDisplayGroupProviderMethodName(String aString)
setEditingContext
public void setEditingContext(com.webobjects.eocontrol.EOEditingContext anEOEditingContext)
setEditingContextProviderMethodName
public void setEditingContextProviderMethodName(String aString)
setEntityName
public void setEntityName(String aString)
setFetchesOnConnect
public void setFetchesOnConnect(boolean aBoolean)
setObjectWithGlobalID
public void setObjectWithGlobalID(com.webobjects.eocontrol.EOGlobalID anEOGlobalID)
setObjectsWithFetchSpecification
public void setObjectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification anEOFetchSpecification)
setResetsEditingContextWhenPreparingForNewTask
public void setResetsEditingContextWhenPreparingForNewTask(boolean aBoolean)
startListeningToDisplayGroup
protected void startListeningToDisplayGroup()
startListeningToEditingContext
protected void startListeningToEditingContext()
stopListeningToDisplayGroup
protected void stopListeningToDisplayGroup()
stopListeningToEditingContext
protected void stopListeningToEditingContext()
takeResposibilityForConnectionOfAssociation
public void takeResposibilityForConnectionOfAssociation(com.webobjects.eointerface.EOAssociation anEOAssociation)
toString
public String toString()
willChange
public void willChange()
© 2001 Apple Computer, Inc. (Last Published April 14, 2001)