|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoapplication.EOController com.webobjects.eoapplication.EOComponentController com.webobjects.eoapplication.EOArchiveController com.webobjects.eoapplication.EOEntityController
The EOEntityController class provides behavior for displaying enterprise objects in a
user interface that can optionally be loaded from an interface file 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.
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 supercontroller 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 a new one.
You can change the way an entity controller gets its editing context by specifying a so-called
provider method with setEditingContextProviderMethodName
. If an entity controller
has an editing context provider method, it gets its editing context by invoking that method.
EOEntityController provides two methods you might find useful as editing context 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 is nested inside a supercontroller's editing
context. If no supercontroller can provide an editing context to be a parent,
nestedEditingContext
simply creates a new editing context.
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 supercontroller. If that supercontroller has the same
entity name and provides 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 an interface
file archive. If the controller still doesn't have a display group, it simply creates a new one.
You can change the way an entity controller gets its display group by specifying a so-called provider
method with setDisplayGroupProviderMethodName
. If an entity controller has a display group
provider method, it gets its display group by invoking that method.
EOEntityController provides two methods you might find useful as display group provider methods:
newDisplayGroup
and newDisplayGroupUsingOptimisticRefresh
. They simply
create new display groups and are convenience methods for setting the provider method.
Editing context and display group provider methods are specified as 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
. To use a method
on a supercontroller, prepend a "^", for example ^customizedEditingContext
.
If the provider method name is the name of a static method, the format of the string is
"CustomApplicationClass
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
.
Nested Class Summary |
Nested classes inherited from class com.webobjects.eoapplication.EOComponentController |
EOComponentController.ActionCollector, EOComponentController.Activation, EOComponentController.EndEditing, EOComponentController.Modal, EOComponentController.ResetUserInterface |
Nested classes inherited from class com.webobjects.eoapplication.EOController |
EOController.Enumeration |
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCoding |
NSKeyValueCoding.DefaultImplementation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.Null, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.Utility, NSKeyValueCoding.ValueAccessor |
Nested classes inherited from class com.webobjects.foundation.NSKeyValueCodingAdditions |
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility |
Field Summary | |
static String |
NestedEditingContextProviderMethodName
The constant describing a the nestedEditingContext editing context provider method name. |
static String |
NewDisplayGroupProviderMethodName
The constant describing a the newDisplayGroup display group provider method name. |
static String |
NewDisplayGroupUsingOptimisticRefreshProviderMethodName
The constant describing a the newDisplayGroupUsingOptimisticRefresh display group provider method name. |
static String |
NewEditingContextProviderMethodName
The constant describing a the newEditingContext editing context provider method name. |
Fields inherited from class com.webobjects.eoapplication.EOComponentController |
Bottom, BottomLeft, BottomRight, Center, Left, Right, Top, TopLeft, TopRight |
Fields inherited from class com.webobjects.eoapplication.EOController |
ControllerAndSubcontrollersEnumeration, ControllerAndSupercontrollersEnumeration, SubcontrollersEnumeration, SupercontrollersEnumeration |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding |
NullValue |
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions |
KeyPathSeparator |
Constructor Summary | |
EOEntityController()
Creates a new entity controller. |
|
EOEntityController(EOXMLUnarchiver unarchiver)
Creates a new entity controller from an EOXMLUnarchiver. |
Method Summary | |
protected void |
connectionWasBroken()
Reacts to the connection for the receiver being broken, taking care of association disconnecting. |
protected void |
connectionWasEstablished()
Reacts to the connection for the receiver being established, taking care of association connecting and fetching if necessary. |
protected void |
controllerDidLoadArchive(NSDictionary namedObjects)
Invoked from loadArchive to notify the receiver that its
interface file has been loaded completely. |
protected void |
controllerWillLoadArchive()
Invoked from loadArchive to notify the receiver that its
interface file is about to be loaded. |
EODisplayGroup |
displayGroup()
Conformance to EOObjectDisplay. |
String |
displayGroupProviderMethodName()
Returns the key path which is used to retrieve the display group for the reveiver. |
protected NSArray |
displayGroupSortOrderings()
Returns the sort orderings to be used with the receiver's display group. |
void |
dispose()
Prepares the receiver so it is disposed when Java performs garbage collection. |
EOEditingContext |
editingContext()
Conformance to EOObjectDisplay. |
String |
editingContextProviderMethodName()
Returns the key path which is used to retrieve the editing context for the reveiver. |
boolean |
endEditing()
Ensures that all editors of the receiver's display groups end editing (flush current user edits to the enterprise object graph if necessary). |
String |
entityName()
Returns the name of the entity of the enterprise objects displayed in the receiver's display group. |
void |
establishConnection()
Overridden from the superclass to ensure that, if an archive name is specified for the receiver, the interface file archive is loaded before the connection is established. |
boolean |
fetchesOnConnect()
Returns whether the receiver should fetch its display group content next time its connection is established. |
void |
handleEditingContextNotification(NSNotification notification)
When starting to listen to an editing context, entity controllers register for several notifications from the editing context. |
boolean |
isFetchesOnConnectEnabled()
Returns whether the receiver should ever fetch its display group content when a connection is established. |
boolean |
isRootEntityController()
Returns whether the receiver is a root entity controller (which is the case if none of the supercontrollers conform to EOObjectDisplay). |
EOEditingContext |
nestedEditingContext()
Creates a new, nested editing context to the editing context from its closest supercontroller conforming to the EOObjectDisplay interface and returning an editing context. |
protected EODataSource |
newDataSource()
Creates and returns a new data source to be used with a display group of the receiver. |
EODisplayGroup |
newDisplayGroup()
Creates a new display group using a data source provided by newDataSource . |
EODisplayGroup |
newDisplayGroupUsingOptimisticRefresh()
Creates a new display group using a data source provided by newDataSource , configured to not use optimistic
refresh. |
EOEditingContext |
newEditingContext()
Creates a new editing context with the default parent object store. |
Object |
objectForOutletPath(EOArchive archive,
String outletPath)
Returns an object for an outlet path to be substituted in an interface file archive loaded by the receiver. |
void |
prepareForNewTask(boolean prepareSubcontrollersForNewTask)
Prepares the receiver for performing a new task by resetting any data and refetching objects if necessary. |
boolean |
resetsEditingContextWhenPreparingForNewTask()
Returns whether the receiver should reset its editing context when preparing for a new task in prepareForNewTask(boolean) . |
EOEnterpriseObject |
selectedObject()
Returns the first enterprise object selected in the receiver's display group. |
EOGlobalID |
selectedObjectGlobalID()
Returns the global ID of the first enterprise object selected in the receiver's display group. |
NSArray |
selectedObjects()
Returns the enterprise objects selected in the receiver's display group. |
NSArray |
selectedObjectsGlobalIDs()
Returns the global IDs of the enterprise objects selected in the receiver's display group. |
void |
setDisplayGroup(EODisplayGroup displayGroup)
Sets the display group used by this controller. |
void |
setDisplayGroupProviderMethodName(String string)
Sets the provider method which is used to retrieve the display group for the reveiver. |
void |
setEditingContext(EOEditingContext editingContext)
Sets the editing context used by this controller. |
void |
setEditingContextProviderMethodName(String string)
Sets the provider method which is used to retrieve the editing context for the reveiver. |
void |
setEntityName(String string)
Sets the entity name of the enterprise objects displayed by the receiver. |
void |
setFetchesOnConnect(boolean flag)
Sets whether the receiver should fetch its display group content next time its connection is established. |
void |
setFetchesOnConnectEnabled(boolean flag)
Sets whether the receiver should ever fetch its display group content when a connection is established. |
void |
setObjectsWithFetchSpecification(EOFetchSpecification fetchSpecification)
Fetches the objects specified by fetchSpecification into
the receiver's display group. |
void |
setObjectsWithGlobalIDs(NSArray globalIDs)
Fetches the objects specified by the global IDs in globalIDs
into the receiver's display group. |
void |
setObjectWithGlobalID(EOGlobalID globalID)
Fetches the object specified by the global ID globalID
into the receiver's display group. |
void |
setResetsEditingContextWhenPreparingForNewTask(boolean flag)
Sets whether the receiver should reset its editing context when preparing for a new task in prepareForNewTask(boolean) . |
protected void |
startListeningToDisplayGroup()
Invoked from setDisplayGroup whenever a new display group is
specified, giving the receiver a chance to react. |
protected void |
startListeningToEditingContext()
Invoked from setEditingContext whenever a new editing context is
specified, giving the receiver a chance to react. |
protected void |
stopListeningToDisplayGroup()
Invoked from setDisplayGroup whenever a display group is
cleared out (if either a new display group is specified or if the display
group is reset to null ), giving the receiver a chance to react. |
protected void |
stopListeningToEditingContext()
Invoked from setEditingContext whenever an editing context is
cleared out (if either a new editing context is specified or if the editing
context is reset to null ), giving the receiver a chance to react. |
void |
takeResposibilityForConnectionOfAssociation(EOAssociation association)
Invoked when one of the receiver's subcontrollers is disposed as a transient controller. |
String |
toString()
Returns the receiver as a string describing the state of the controller. |
Methods inherited from class com.webobjects.eoapplication.EOArchiveController |
archiveName, controllerDisplayGroup, hasControllerDisplayGroup, loadArchive, objectWillChange, prepareComponent, setArchiveName, setControllerDisplayGroup, willChange |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.webobjects.eoapplication.EOObjectDisplay |
controllerDisplayGroup |
Field Detail |
public static final String NestedEditingContextProviderMethodName
nestedEditingContext
editing context provider method name.
public static final String NewDisplayGroupProviderMethodName
newDisplayGroup
display group provider method name.
public static final String NewDisplayGroupUsingOptimisticRefreshProviderMethodName
newDisplayGroupUsingOptimisticRefresh
display group provider method name.
public static final String NewEditingContextProviderMethodName
newEditingContext
editing context provider method name.
Constructor Detail |
public EOEntityController()
public EOEntityController(EOXMLUnarchiver unarchiver)
unarchiver
- the unarchiver providing XML attributesMethod Detail |
protected void connectionWasBroken()
connectionWasBroken
in class EOController
EOController.breakConnection()
protected void connectionWasEstablished()
connectionWasEstablished
in class EOController
EOController.establishConnection()
protected void controllerDidLoadArchive(NSDictionary namedObjects)
loadArchive
to notify the receiver that its
interface file has been loaded completely. You can override this method
to perform additional initialization for the objects loaded from the
interface file archive.
controllerDidLoadArchive
in class EOArchiveController
namedObjects
- dictionary with all named objects from the interface file archive (keys: names, values: objects)EOArchiveController.loadArchive()
protected void controllerWillLoadArchive()
loadArchive
to notify the receiver that its
interface file is about to be loaded. You can override this method
to perform additional preparation for the archive loading process.
controllerWillLoadArchive
in class EOArchiveController
EOArchiveController.loadArchive()
public EODisplayGroup displayGroup()
displayGroup
in interface EOObjectDisplay
setDisplayGroup(EODisplayGroup)
,
displayGroupSortOrderings()
public String displayGroupProviderMethodName()
newDisplayGroup
and newDisplayGroupUsingOptimisticRefresh
.
setDisplayGroupProviderMethodName(String)
,
displayGroup()
,
newDisplayGroup()
,
newDisplayGroupUsingOptimisticRefresh()
protected NSArray displayGroupSortOrderings()
null
. Note that the
display group sort orderings might be overridden by table associations
unless they are configured to not change the display group sort orderings.
public void dispose()
dispose
in interface NSDisposable
dispose
in class EOComponentController
public EOEditingContext editingContext()
editingContext
in interface EOObjectDisplay
setEditingContext(EOEditingContext)
public String editingContextProviderMethodName()
newEditingContext
and nestedEditingContext
.
setEditingContextProviderMethodName(String)
,
editingContext()
,
newEditingContext()
,
nestedEditingContext()
public boolean endEditing()
endEditing
in interface EOComponentController.EndEditing
endEditing
in class EOArchiveController
true
if all uncommitted changes were successfully flushed; false
otherwisepublic String entityName()
EOObjectDisplay
entityName
in interface EOObjectDisplay
public void establishConnection()
establishConnection
in class EOController
EOController.connectionWasEstablished()
,
EOController.establishConnectionToSupercontrollers()
public boolean fetchesOnConnect()
true
.
Once it retrieves objects explicitly (for example from a global ID) or actually
performs the fetch while connecting, it sets this flag to false
.
true
if the controller should fetch its display group content next time
its connection is established; false
otherwisesetFetchesOnConnect(boolean)
public void handleEditingContextNotification(NSNotification notification)
notification
- the editing context notificationstartListeningToEditingContext()
public boolean isFetchesOnConnectEnabled()
true
if the controller will use fetchesOnConnect()
to decide whether or not to fetch its display group content next time
its connection is established; false
if the controller will never
fetch its display group content when a connection is establishedsetFetchesOnConnectEnabled(boolean)
,
fetchesOnConnect()
public boolean isRootEntityController()
true
if the controller is a root entity controller; false
otherwisepublic EOEditingContext nestedEditingContext()
setEditingContextProviderMethodName(String)
protected EODataSource newDataSource()
entityName
.
entityName()
public EODisplayGroup newDisplayGroup()
newDataSource
. This method can be used as display
group provider method.
newDisplayGroupUsingOptimisticRefresh()
,
setDisplayGroupProviderMethodName(String)
public EODisplayGroup newDisplayGroupUsingOptimisticRefresh()
newDataSource
, configured to not use optimistic
refresh. This method can be used as display group provider method.
newDisplayGroup()
,
setDisplayGroupProviderMethodName(String)
public EOEditingContext newEditingContext()
setEditingContextProviderMethodName(String)
public Object objectForOutletPath(EOArchive archive, String outletPath)
editingContext
of the receiver (which is the file's owner of the archive)
or displayGroup.dataSource
. If no substitution object is needed, this
method returns null
.
archive
- the archive currently loadedoutletPath
- the outlet path to find a substitution object for
EOArchiveController.loadArchive()
public void prepareForNewTask(boolean prepareSubcontrollersForNewTask)
prepareForNewTask
in class EOController
prepareSubcontrollersForNewTask
- true
if the method should be forwarded
to all subcontrollers; false
otherwisepublic boolean resetsEditingContextWhenPreparingForNewTask()
prepareForNewTask(boolean)
. The default is
true
.
true
if the controller resets its editing context while preparing for a new task;
false
otherwisepublic EOEnterpriseObject selectedObject()
public EOGlobalID selectedObjectGlobalID()
public NSArray selectedObjects()
public NSArray selectedObjectsGlobalIDs()
public void setDisplayGroup(EODisplayGroup displayGroup)
stopListeningToDisplayGroup
first. After setting the
new display group, it invokes startListeningToDisplayGroup
.
displayGroup
- the display group to be used by this controllerdisplayGroup()
,
startListeningToDisplayGroup()
,
stopListeningToDisplayGroup()
public void setDisplayGroupProviderMethodName(String string)
newDisplayGroup
and newDisplayGroupUsingOptimisticRefresh
. See the EOEntityController
class description for how to specify a provider method.
string
- the provider method used to retrieve the display group for the receiverdisplayGroupProviderMethodName()
,
displayGroup()
,
newDisplayGroup()
,
newDisplayGroupUsingOptimisticRefresh()
public void setEditingContext(EOEditingContext editingContext)
stopListeningToEditingContext
first. After setting the
new editing context, it invokes startListeningToEditingContext
.
editingContext
- the editing context to be used by this controllereditingContext()
,
startListeningToEditingContext()
,
stopListeningToEditingContext()
public void setEditingContextProviderMethodName(String string)
newEditingContext
and nestedEditingContext
. See the EOEntityController class description
for how to specify a provider method.
string
- the provider method used to retrieve the editing context for the receivereditingContextProviderMethodName()
,
editingContext()
,
newEditingContext()
,
nestedEditingContext()
public void setEntityName(String string)
string
- the entity name of the enterprise objects displayed by the receiverpublic void setFetchesOnConnect(boolean flag)
true
.
Once it retrieves objects explicitly (for example from a global ID) or actually
performs the fetch while connecting, it sets this flag to false
.
flag
- true
if the controller should fetch its display group content next time
its connection is established; false
otherwisefetchesOnConnect()
public void setFetchesOnConnectEnabled(boolean flag)
flag
- true
if the controller should use fetchesOnConnect()
to decide whether or not to fetch its display group content next time
its connection is established; false
if the controller should never
fetch its display group content when a connection is establishedfetchesOnConnect()
,
isFetchesOnConnectEnabled()
public void setObjectWithGlobalID(EOGlobalID globalID)
globalID
into the receiver's display group.
globalID
- the global ID specifying the object to be fetchedpublic void setObjectsWithFetchSpecification(EOFetchSpecification fetchSpecification)
fetchSpecification
into
the receiver's display group.
fetchSpecification
- the fetch specifiation to fetch objectspublic void setObjectsWithGlobalIDs(NSArray globalIDs)
globalIDs
into the receiver's display group.
globalIDs
- the array of global IDs specifying the object to be fetchedpublic void setResetsEditingContextWhenPreparingForNewTask(boolean flag)
prepareForNewTask(boolean)
. The default is
true
.
flag
- true
if the controller resets its editing context while preparing for a new task;
false
otherwiseprotected void startListeningToDisplayGroup()
setDisplayGroup
whenever a new display group is
specified, giving the receiver a chance to react. EOEntityController's default
implementation registers itself as observer for the display group in the
EOObserverCenter. When this method is invoked, displayGroup
already
returns the new display group of the controller.
displayGroup()
,
setDisplayGroup(EODisplayGroup)
,
stopListeningToDisplayGroup()
protected void startListeningToEditingContext()
setEditingContext
whenever a new editing context is
specified, giving the receiver a chance to react. EOEntityController's default
implementation registers for its handleEditingContextNotification
method as receiver for the notifications
EOEditingContext.ObjectsChangedInEditingContextNotification
and
EOEditingContext.EditingContextDidSaveChangesNotification
. When
this method is invoked, editingContext
already returns the new
editing context of the controller.
editingContext()
,
setEditingContext(EOEditingContext)
,
stopListeningToEditingContext()
protected void stopListeningToDisplayGroup()
setDisplayGroup
whenever a display group is
cleared out (if either a new display group is specified or if the display
group is reset to null
), giving the receiver a chance to react.
EOEntityController's default implementation unregisters itself as observer
from the display group (as registered in startListeningToDisplayGroup
).
When this method is invoked, displayGroup
still returns the old
display group of the controller.
displayGroup()
,
setDisplayGroup(EODisplayGroup)
,
startListeningToDisplayGroup()
protected void stopListeningToEditingContext()
setEditingContext
whenever an editing context is
cleared out (if either a new editing context is specified or if the editing
context is reset to null
), giving the receiver a chance to react.
EOEntityController's default implementation unregisters the notficiations
registered in startListeningToEditingContext
. When this
method is invoked, editingContext
still returns the old
editing context of the controller.
editingContext()
,
setEditingContext(EOEditingContext)
,
startListeningToEditingContext()
public void takeResposibilityForConnectionOfAssociation(EOAssociation association)
EOAssociationConnector
association
.
takeResposibilityForConnectionOfAssociation
in interface EOAssociationConnector
association
- the transient subcontroller's EOAssociationpublic String toString()
toString
in class EOArchiveController
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |