Undo feature

Undo feature

Old forum URL: forums.lhotka.net/forums/t/3317.aspx


rossl123 posted on Friday, August 03, 2007

Here's hoping someone can help.

I am still using V1.0 and having trouble with undo. After screen edits have been made to a my business object, when the user chooses to cancel I have invoked the CancelEdit funtion, but I find that only the last edit has been undone. What I was expecting was that all edits back to level 0 would be rolled back off the stack.

Is this something that is a problem or a feature limitation with V1.0 or am I missing something?

Thanks for reading my post.

Ross

ajj3085 replied on Friday, August 03, 2007

Remember that the undo is an n-level undo.. so they are nested.  For each call to BeginEdit, you'll need to call CancelEdit.

If you're using databinding though, you shouldn't be calling those methods at all; that's databindings responsibility.

HTH
Andy

rossl123 replied on Sunday, August 05, 2007

Thanks for your reply Andy.

It seems that I have come unstuck in my implementation of the original VB.Net code. Since I began using CSLA before the C# release, I had to hand code the VB.Net version to C#. When the C# version came along I merely checked the implementation was the same as mine and applied some of the erratum as appropriate. It appears that the code in the IEditableObject region in BusinessBase must have been added, or I missed converting it somehow in the first place. It is this code that manages the updates from the binder and allows the n-level undo to be overriden at the form level, hence act as a Cancel operation at that level rather than an Undo.

It was your mention of the fact that I shouldn't have been using the methods that got me pointed in the right direction, because, as it is true that these methods aren't needed in a web environment, in windows forms they are, because of the stateful environment. Which led me back to the book, and comparing code line by line and...

Thanks again
Ross

Copyright (c) Marimer LLC