Skip to main content

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.


Anonymous said…
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:

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
Anonymous said…
Hi! Did you saw test case link and description, what I add to this post comment?

Best regards, Kristaps!

Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…