Undoing changes using Middle Tier Savepoints

While building applications, sometimes you may need to enable undo/redo functionality for your pages. If you use ADF BC for implementing the business services, then one possibility is to leverage the 'Middle-Tier Savepoints' to rollback to a certain point within a transaction instead of rolling back the
entire transaction. Below shown APIs are your friends here.
ApplicationModuleImpl::passivateStateForUndo(java.lang.String id, byte[] clientData, int flags)
ApplicationModuleImpl::activateStateForUndo(java.lang.String id,int flags)

More details can be found in Fusion Developer's Guide - 40.9 Using State Management for Middle-Tier Savepoints. You may need to note down a couple of point here.
1. This approach saves only ADF Model state(in other words , this wouldn't help you to save navigation state/manged bean/memory scope scope variable)
2. Saved state(snapshot) do not survive past duration of transaction

Adding Save Points to a Task Flow

Please note that Oracle ADF provides a declarative approach to working with savepoints, described in Section 18.7, Adding Save Points to a Task Flow. This is different from the approach discussed in this post. In this approach, save point is managed by the ADF Controller. Worth noting the following points associated with 'ADF Controller Save Points' functionality.
1. Declarative
2. Saves UI state, ManagedBean state,Navigation State and ADF Model state
3. Can be restored at later stage, sate is persisted in databases.
4. This is useful, if you need to enable this functionality(restoring save point) for a bounded taskflow


You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

How to run this sample?

Please try running sample-task-flow-definition . Default activity for this taskflow creates the save point by calling passivateStateForUndo(...). The 'Cancel' button in editDept.jspx is mapped to activateStateForUndo method in the ApplicationModule. This method restores the previously saved state.

Comments

  1. Hi, Jobinesh! First I want to thanks for your answer and new post. But I still have problem refreshing my elements in page. On Your example I created my test case. You can download this testCase there: http://www.failiem.lv/down.php?i=xecqbw&n=UndoChangesSampleWithAjax.zip

    You don't need to change DB conn. settings, can use mine. Please run sample-task-flow-definition. Then You might be on record DepartmentId = 10 and DepartmentName = 1. Change DepartmentName to value '2'. Then near DepartmentName field, in read only input text field would be value 'High' (red color). After press Cancel button the DepartmentName value are orginal - '1'. But read only input text field near it would not be orginal. :( Hope You understand may problem. If no, let me know. What can I do in this situation, and where is problem?
    Best regards, hope for Your response and solution on my problem, Kristaps

    ReplyDelete
  2. Hi! Did you saw test case link and description, what I add to this post comment?

    Best regards, Kristaps!

    ReplyDelete

Post a Comment