|
WebObjects 5.2 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
The EOEditingContext.Delegate interface defines methods that an
EOEditingContext can invoke in its delegate. Delegates are not required to
provide implementations for all of the methods in the interface, and you
do not have to use the implements
keyword to specify that the object
implements the Delegate interface. Instead, declare and implement any
subset of the methods declared in the interface that you need, and use the
EOEditingContext method setDelegate
method to assign the object as the
delegate. An editing context can determine if the delegate doesn't
implement a delegate method and only attempts to invoke the methods the
delegate actually implements.
Method Summary | |
void |
editingContextDidMergeChanges(EOEditingContext context)
Invoked once after a batch of objects has been updated in anEditingContext 's parent object store (in response to an
ObjectsChangedInStoreNotification). |
NSArray |
editingContextShouldFetchObjects(EOEditingContext context,
EOFetchSpecification fetchSpec)
Invoked from objectsWithFetchSpecification . |
boolean |
editingContextShouldInvalidateObject(EOEditingContext context,
EOEnterpriseObject object,
EOGlobalID globalID)
Sent when an object identified by globalID has
been explicitly invalidated. |
boolean |
editingContextShouldMergeChangesForObject(EOEditingContext context,
EOEnterpriseObject object)
When an ObjectsChangedInStoreNotification is received, anEditingContext invokes this method in its delegate
once for each of the objects that has both uncommitted changes
and an update from the EOObjectStore. |
boolean |
editingContextShouldPresentException(EOEditingContext context,
Throwable exception)
Sent whenever an exception is caught by an EOEditingContext. |
boolean |
editingContextShouldUndoUserActionsAfterFailure(EOEditingContext context)
Sent when a validation error occurs while processing a processRecentChanges message. |
boolean |
editingContextShouldValidateChanges(EOEditingContext context)
Sent when an EOEditingContext receives a saveChanges message. |
void |
editingContextWillSaveChanges(EOEditingContext context)
Sent when an EOEditingContext receives a saveChanges message. |
Method Detail |
public void editingContextDidMergeChanges(EOEditingContext context)
Invoked once after a batch of objects has been updated in
anEditingContext
's parent object store (in response to an
ObjectsChangedInStoreNotification). A delegate might implement this
method to define custom merging behavior, most likely in conjunction
with EOEditingContext.editingContextShouldMergeChangesForObject.
It is safe for this method to make changes to the objects in
the editing context.
context
- The target EOEditingContexteditingContextShouldMergeChangesForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)
public NSArray editingContextShouldFetchObjects(EOEditingContext context, EOFetchSpecification fetchSpec)
objectsWithFetchSpecification
. If the delegate has
appropriate results cached it can return them and the fetch will
be bypassed. Returning null
causes the fetch to be
propagated to the parent object store.context
- The target EOEditingContextfetchSpec
- the fetch specificationnull
to pass the fetch request to the parent object store, otherwise an array of resultsEOEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext)
public boolean editingContextShouldInvalidateObject(EOEditingContext context, EOEnterpriseObject object, EOGlobalID globalID)
Sent when an object
identified by globalID
has
been explicitly invalidated. If the delegate returns false,
the invalidation is refused. This allows the delegate to
selectively override object invalidations.
context
- The target EOEditingContextobject
- the object identified by globalidglobalID
- the globalID corresponding to object
true
if the invalidation is permissible.EOEditingContext.invalidateAllObjects()
,
EOEditingContext.reset()
public boolean editingContextShouldMergeChangesForObject(EOEditingContext context, EOEnterpriseObject object)
When an ObjectsChangedInStoreNotification is received,
anEditingContext
invokes this method in its delegate
once for each of the objects that has both uncommitted changes
and an update from the EOObjectStore. This method is invoked
before any updates actually occur.
If this method returns true, all of the uncommitted changes
should be merged into the object after the update is applied,
in effect preserving the uncommitted changes (the default behavior).
The delegate method editingContextShouldInvalidateObject
will
not be sent for the object in question.
If this method returns false, no uncommitted changes are applied. Thus, the object is updated to reflect the values from the database exactly. This method should not make any changes to the object since it is about to be invalidated.
If you want to provide custom merging behavior, you need to
implement both this method and editingContextDidMergeChanges
.
You use editingContextShouldMergeChangesForObject
to save
information about each changed object and return true to allow
merging to continue. After the default merging behavior occurs,
editingContextDidMergeChanges
is invoked, at which point
you implement the custom behavior.
context
- The target EOEditingContextobject
- the object that underwent changestrue
if all uncommitted changes should be merged into object
after the updatepublic boolean editingContextShouldPresentException(EOEditingContext context, Throwable exception)
false
, exception
is ignored.
Otherwise (if the delegate returns true, if the editing context
doesn't have a delegate, or if the delegate doesn't implement
this method) exception
is passed to the message handler
for further processing.context
- The target EOEditingContextexception
- the exception caught by an EOEditingContextfalse
if the exception should be ignoredEOEditingContext.messageHandler()
public boolean editingContextShouldUndoUserActionsAfterFailure(EOEditingContext context)
Sent when a validation error occurs while processing a
processRecentChanges
message. If the delegate returns false,
it disables the automatic undoing of user actions after validation
has resulted in an error.
By default, if a user attempts to perform an action that results in a validation failure (such as deleting a department object that has a delete rule stating that the department can't be deleted if it contains employees), the user's action is immediately rolled back. However, if this delegate method returns false, the user action is allowed to stand (though attempting to save the changes to the database without solving the validation error will still result in a failure). Returning false gives the user an opportunity to correct the validation problem so that the operation can proceed (for example, the user might delete all of the department's employees so that the department itself can be deleted).
context
- The target EOEditingContexttrue
if the context
should automatically undo user actions which cause a validation errorEOEditingContext.processRecentChanges()
public boolean editingContextShouldValidateChanges(EOEditingContext context)
saveChanges
message.
If the delegate returns false, changes are saved without first
performing validation. This method can be useful if the delegate
wants to provide its own validation mechanism.context
- The target EOEditingContexttrue
if changes should be validatedEOEditingContext.saveChanges()
public void editingContextWillSaveChanges(EOEditingContext context)
saveChanges
message.
The delegate can throw an exception to abort the save operation.context
- The target EOEditingContextEOEditingContext.saveChanges()
|
Last updated Fri Feb 21 13:15:00 PST 2003. | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |