Re: processRecentChanges without UndoManager
Re: processRecentChanges without UndoManager
- Subject: Re: processRecentChanges without UndoManager
- From: Christian Pekeler <email@hidden>
- Date: Wed, 3 Nov 2004 16:33:35 -0700
Thanks Chuck,
I'm working around this problem now by overwriting
_processRecentChanges in my subclass of EOEditingContext.
protected boolean _processRecentChanges() {
if (undoManager() != null)
return super._processRecentChanges();
setUndoManager(new NSUndoManager());
try {
return super._processRecentChanges();
} finally {
setUndoManager(null);
}
}
That appears to be working fine.
Christian
On Nov 3, 2004, at 11:11 AM, Chuck Hill wrote:
It is a bug in the handling of exceptions raised when validating a
delete.
Though the actual root issue is somewhat up for debate. IMHO, if the
EC
needs a undo manager for this internal processes it should damn well
create
its own and not mess with mine! To make this really, really fun --
wait
for it -- if you _do_ have an undo manager and validateForDelete
raises,
then the undo manager is rolled back one or more undo group _too far_.
Yep, so not only does it recover from the failed deletion it (and I
really,
really love this) rolls all the objects in the EC to their state
before the
last save. Imagine the fun that I had tracking that bug down. So now
I
try to ensure that validateForDelete can't raise before I call
saveChanges
and remove all actions from the undo manager immediately after a
successful
save. From all this I deduce that very few people are using deny
delete
rules or otherwise causing validateForDeletion to raise.
Chuck
At 10:55 AM 03/11/2004 -0700, Christian Pekeler wrote:
I don't explicitly use an undo manager in my WO project. The
documentation for EOEditingContext.setUndoManager says:
You might invoke this method with null if the application doesn't
need
undo and you want to avoid the overhead of an undo stack.
It seems like EOEditingContext is using the undo manager internally,
because if I do this:
editingContext.setUndoManager(null);
UndeletableEntity undeletableEntity = new UndeletableEntity();
editingContext.insertObject(undeletableEntity);
editingContext.deleteObject(undeletableEntity);
editingContext.saveChanges();
with:
public class UndeletableEntity extends EOGenericRecord {
...
public void validateForDelete() throws
NSValidation.ValidationException {
super.validateForDelete();
throw new ValidationException("preventing deletion for testing
purposes");
}
}
I get:
java.lang.IllegalStateException: Editing context needs an undo manager
to recover from delete propagation problems. Do not set the undo
manager of this editing context to null
at
com.webobjects.eocontrol.EOEditingContext._processRecentChanges(EOEdit
in
gContext.java:1694)
at
com.webobjects.eocontrol.EOEditingContext._prepareForPushChanges(EOEdi
ti
ngContext.java:3179)
at
com.webobjects.eocontrol.EOEditingContext.saveChanges(EOEditingContext
.j
ava:3135)
So apparently it is not OK to set the undo manager to null. Am I
misunderstanding something or is this a bug in
EOEditingContext._processRecentChanges()?
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden