WebObjects 5.2.3

com.webobjects.eocontrol
Interface EOEditingContext.Delegate

Enclosing interface:
EOEditingContext

public static interface EOEditingContext.Delegate

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)
          If the delegate has appropriate results cached it can return them and the fetch will be bypassed.
 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

editingContextDidMergeChanges

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.

Parameters:
context - The target EOEditingContext
See Also:
editingContextShouldMergeChangesForObject(com.webobjects.eocontrol.EOEditingContext, com.webobjects.eocontrol.EOEnterpriseObject)

editingContextShouldFetchObjects

public NSArray editingContextShouldFetchObjects(EOEditingContext context,
                                                EOFetchSpecification fetchSpec)
If the delegate has appropriate results cached it can return them and the fetch will be bypassed. Invoked from objectsWithFetchSpecification. Returning null causes the fetch to be propagated to the parent object store.

Parameters:
context - The target EOEditingContext
fetchSpec - the fetch specification
Returns:
null to pass the fetch request to the parent object store, otherwise an array of results
See Also:
EOEditingContext.objectsWithFetchSpecification(com.webobjects.eocontrol.EOFetchSpecification, com.webobjects.eocontrol.EOEditingContext)

editingContextShouldInvalidateObject

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.

Parameters:
context - The target EOEditingContext
object - the object identified by globalid
globalID - the globalID corresponding to object
Returns:
true if the invalidation is permissible.
See Also:
EOEditingContext.invalidateAllObjects(), EOEditingContext.reset()

editingContextShouldMergeChangesForObject

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.

Parameters:
context - The target EOEditingContext
object - the object that underwent changes
Returns:
true if all uncommitted changes should be merged into object after the update

editingContextShouldPresentException

public boolean editingContextShouldPresentException(EOEditingContext context,
                                                    Throwable exception)
Sent whenever an exception is caught by an EOEditingContext. If the delegate returns 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.

Parameters:
context - The target EOEditingContext
exception - the exception caught by an EOEditingContext
Returns:
false if the exception should be ignored
See Also:
EOEditingContext.messageHandler()

editingContextShouldUndoUserActionsAfterFailure

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).

Parameters:
context - The target EOEditingContext
Returns:
true if the context should automatically undo user actions which cause a validation error
See Also:
EOEditingContext.processRecentChanges()

editingContextShouldValidateChanges

public boolean editingContextShouldValidateChanges(EOEditingContext context)
Sent when an EOEditingContext receives a 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.

Parameters:
context - The target EOEditingContext
Returns:
true if changes should be validated
See Also:
EOEditingContext.saveChanges()

editingContextWillSaveChanges

public void editingContextWillSaveChanges(EOEditingContext context)
Sent when an EOEditingContext receives a saveChanges message. The delegate can throw an exception to abort the save operation.

Parameters:
context - The target EOEditingContext
See Also:
EOEditingContext.saveChanges()

Last updated Thu Oct 21 15:04:16 PDT 2004.

Copyright © 2004 Apple Computer, Inc.