Documentation Archive Developer
Search
PATH  Documentation > WebObjects 4.5 > EOControl Reference

Table of Contents

EOEditingContext Delegate


(informal protocol)
Declared in:
EOControl/EOEditingContext.h



Protocol Description


The EOEditingContext Delegate informal protocol defines methods that an EOEditingContext can invoke in its delegate. Delegates are not required to provide implementations for all of the methods in the informal protocol. Instead, declare and implement any subset of the methods declared in the informal protocol that you need, and use the EOEditingContext method setDelegate: method to assign your 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 Types


Fetching objects
- editingContext:shouldFetchObjectsDescribedByFetchSpecification:
Invalidating objects
- editingContext:shouldInvalidateObject:globalID:
Saving changes
- editingContextWillSaveChanges:
Handling failures
- editingContextShouldValidateChanges:
- editingContext:shouldPresentException:
- editingContextShouldUndoUserActionsAfterFailure:
Merging changes
- editingContext:shouldMergeChangesForObject:
- editingContextDidMergeChanges:


Instance Methods



editingContextDidMergeChanges:

- (void)editingContextDidMergeChanges:(EOEditingContext *)anEditingContext

Invoked once after a batch of objects has been updated in anEditingContext's parent object store (in response to an EOObjectsChangedInStoreNotification). A delegate might implement this method to define custom merging behavior, most likely in conjunction with editingContext:shouldMergeChangesForObject:. It is safe for this method to make changes to the objects in the editing context.



editingContext:shouldFetchObjectsDescribedByFetchSpecification:

- (NSArray *)editingContext:(EOEditingContext *)editingContext shouldFetchObjectsDescribedByFetchSpecification:(EOFetchSpecification *)fetchSpecification

Invoked from objectsWithFetchSpecification:editingContext:. If the delegate has appropriate results cached it can return them and the fetch will be bypassed. Returning nil causes the fetch to be propagated to the parent object store.

editingContext:shouldInvalidateObject:globalID:

- (BOOL)editingContext:(EOEditingContext *)anEditingContext shouldInvalidateObject:(id)object globalID:(EOGlobalID *)globalID

Sent when an object identified by globalID has been explicitly invalidated. If the delegate returns NO, the invalidation is refused. This allows the delegate to selectively override object invalidations.

See Also: - invalidateAllObjects, - revert



editingContext:shouldMergeChangesForObject:

- (BOOL)editingContext:(EOEditingContext *)anEditingContext shouldMergeChangesForObject:(id)object

When an EOObjectsChangedInStoreNotification 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 YES, 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 editingContext:shouldInvalidateObject:globalID: will not be sent for the object in question.

If this method returns NO, 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 editingContext:shouldMergeChangesForObject: to save information about each changed object and return YES to allow merging to continue. After the default merging behavior occurs, editingContextDidMergeChanges: is invoked, at which point you implement your custom behavior.



editingContext:shouldPresentException:

- (BOOL)editingContext:(EOEditingContext *)anEditingContext shouldPresentException:(NSException *)exception

Sent whenever an exception is caught by an EOEditingContext. If the delegate returns NO, exception is ignored. Otherwise (if the delegate returns YES, 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,

See Also: - messageHandler



editingContextShouldUndoUserActionsAfterFailure:

- (BOOL)editingContextShouldUndoUserActionsAfterFailure:(EOEditingContext *)anEditingContext

Sent when a validation error occurs while processing a processRecentChanges message. If the delegate returns NO, 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 NO, 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 NO 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).



editingContextShouldValidateChanges:

- (BOOL)editingContextShouldValidateChanges:(EOEditingContext *)anEditingContext

Sent when an EOEditingContext receives a saveChanges message. If the delegate returns NO, changes are saved without first performing validation. This method can be useful if the delegate wants to provide its own validation mechanism.

editingContextWillSaveChanges:

- (void)editingContextWillSaveChanges:(EOEditingContext *)editingContext

Sent when an EOEditingContext receives a saveChanges message. The delegate can raise an exception to abort the save operation.


Table of Contents