Difference between Undo() and RejectChanges()


Author
Message
StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
1. What editing state is the BO set to when Undo() is called? I checked the object browser and it doesn't have anything.

Calling Undo() will always set the editing state of the business object back to idle.

2. When it updates the bound controls will it update to the previous values (empty/default values in the case of adding a new row) or the current values of the bound controls (I assume the former)?

It will update to the former (previous values)... however, if you call Undo() after you have added a row, the values of that new row will not be set back to default... the row itself will be removed from the business object and it will navigate to an adjacent row.

3. If a SaveUndoResult is anything other than success, what is the editing state of the BO?

Whatever the state was before Save() was called... the state is not changed if Save() does not return Success.

PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
Trent L. Taylor (10/19/2007)
Peter,



The RejectChanges basically exposes the RejectChanges method on the CurrentDataTable. The Undo changes the state of the BO and will refresh any bounds controls, etc.



In most cases you will want to call the Undo() on the BO as this will call the RejectChanges internally on the CurrentDataTable as well as update the state of the object and any bounds controls. The only time that you will want to call RejectChanges is when you want the BO to be ignorant of what is going on.



Greg also has a good point that you can use the Object Browser, look at the source code, or Reflector to see what is going on behind the scenes. Sometimes this will give you a better idea of what action is taking place.




New elements to the question.



1. What editing state is the BO set to when Undo() is called? I checked the object browser and it doesn't have anything.



2. When it updates the bound controls will it update to the previous values (empty/default values in the case of adding a new row) or the current values of the bound controls (I assume the former)?



3. If a SaveUndoResult is anything other than success, what is the editing state of the BO?



Thanks!
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Peter,

The RejectChanges basically exposes the RejectChanges method on the CurrentDataTable.  The Undo changes the state of the BO and will refresh any bounds controls, etc.

In most cases you will want to call the Undo() on the BO as this will call the RejectChanges internally on the CurrentDataTable as well as update the state of the object and any bounds controls.  The only time that you will want to call RejectChanges is when you want the BO to be ignorant of what is going on. 

Greg also has a good point that you can use the Object Browser, look at the source code, or Reflector to see what is going on behind the scenes.  Sometimes this will give you a better idea of what action is taking place.

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (4.8K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Peter,



Don't forget about the Object browser. Some times there is more information there.



In looking at the description in Object Browser, I'm guessing that RejectChanges would be used if you manually modified the underlying data table of a BO and then wanted to back out of the changes. It says that it also updates bound controls. However, I'm guessing that it doesn't change the editing state.



What I do know is that based on what you've said, Undo is the one to use. It undoes any changes to the underlying datatable, updates bound controls, resets the editing state. Undo is what is called if you click on Undo of the MaintenanceFormToolstrip.



Hope that helps!
PeterA
PeterA
StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)StrataFrame Novice (78 reputation)
Group: Forum Members
Posts: 72, Visits: 235
I've been trying to figure out the different behaviors between these two methods. If I want to cancel changes, which one should I call?



What I have is an edit form that has a cancel button to return the user to a detailed information or listing page. Should they change their mind and not want to add a new record to the business object or edit one of the records, they can click Cancel. This fires off the click event for the button and before I send them back to the detail/listing, I need to reset the EditingState to Idle. Does BusinessObject.Undo() take care of that? Or should I be using BusinessObject.RejectChanges() instead -- just in case they changed some values in a bound field?



I didn't find anything in the documentation about the use of these two methods (again). Some more information would really help.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search