Jtable model
Hello Java Guru's
I want to track the user changes in the Jtable model.
I can able to track the changes but what if the user decided to retain the changes.
For example: One text field they changed from Pizza to Sandwich, But they decided to put back Pizza. If the changed back to old value then i dont have to update the database.
Can anyone done like this before?
Thanks in advance.
[422 byte] By [
a_devana] at [2007-10-2 20:26:10]

You mean like "undo / redo"?
If it is like this, when the user types a new value, just save a copy of your table in memory (auxiliary instance of your class) before you change the value in your data structure. When the user presses ctrl-z (undo) you just load the copy.
hope I could help
Leo77a at 2007-7-13 23:09:08 >

The inefficient method would be to maintain a copy of the model as it exists in the database. Then when you are going to save the changes to the database, just save the differences between the two.
You could do some improvements like keeping track of the number of changes. Or maintaining a list of changes (with the previous / database value) and if a change is made to a previously changed item, update the change list.