This post is extension for my previous posts about ADF CRUD and is based on - ADF Query Search and Results Form blog. As most likely you have noticed it already, Rollback operation in ADF removed all pending changes plus it resets current row to the first row in data collection. Resetting current row to the first is not always desirable, I will provide sample application which demonstrates how to prevent resetting to first row after Rollback operation was invoked.
Download completed sample application - ADFCRUDRollbackApp.zip. There are two ADF BC generic classes with overridden methods you should pay attention for in this sample - GenericVOImpl and GenericAMImpl.
GenericVOImpl contains beforeRollback(...) and afterRollback(...) overridden methods. beforeRollback(...) is responsible to retrieve and store current row key and range index (so we can reset it back):
afterRollback(...) method sets current row key back and scrolls to current row range (this allows to preserve current row on the UI with single generic and reusable implementation in ADF BC):
You must override prepareSession(...) method in Application Module generic class and disable clearing cache on rollback (otherwise nothing will help to keep current row, even setting it programmatically):
Let's do a test now - search with ADF Query and scroll few records, we can change hire date value:
Press Cancel button now:
Unsaved data will be cleaned and data row restored to its original state - current row remains the same:
Download completed sample application - ADFCRUDRollbackApp.zip. There are two ADF BC generic classes with overridden methods you should pay attention for in this sample - GenericVOImpl and GenericAMImpl.
GenericVOImpl contains beforeRollback(...) and afterRollback(...) overridden methods. beforeRollback(...) is responsible to retrieve and store current row key and range index (so we can reset it back):
afterRollback(...) method sets current row key back and scrolls to current row range (this allows to preserve current row on the UI with single generic and reusable implementation in ADF BC):
You must override prepareSession(...) method in Application Module generic class and disable clearing cache on rollback (otherwise nothing will help to keep current row, even setting it programmatically):
Let's do a test now - search with ADF Query and scroll few records, we can change hire date value:
Press Cancel button now:
Unsaved data will be cleaned and data row restored to its original state - current row remains the same: