This blog post will be based on ADF Developer Guide section - 24.7 Using Save Points in Task Flows. I will be describing out of the box 'save for later' functionality provided by ADF BC (Model) and ADF Task Flows (Controller). This will be especially useful for complex forms, where users would prefer to save their work in progress and come back to it later, to finish with the remaining details. We could split transaction and allow to complete that transaction later, even during next login. Such functionality can be achieved with ADF out of the box feature - Save Points (see link to the documentation provided above). In the background Save Point functionality is based on passivation/activation process handled in PS_TXN table. Save point is creating labels and associating these labels with temporary data stored in PS_TXN.
Sample application - ADFTaskFlowSavePointApp.zip, is enabled with Save Points. To enable Save Points support, is enough to provide Data Source for the Save Points:
ADF application should create required table for Save Points automatically, same as PS_TXN table. Table for Save Points - ORADFCSAVPT. This table keeps information about current Save Points for every user:
ADF Task Flow, where we would enable Save Points is same as any other ADF Task Flow. There is only one extra activity created - Save Point Restore. This activity takes Save Point ID and restores it:
Save Point Restore activity takes Save Point ID to restore through property:
Looking from UI perspective, Save Point management can be implemented with options to create Save Point, display a list of previously created Save Points and restore one of the selected Save Points:
Create Save Point method is using Save Point Manager API to create new Save Point:
The same Save Point Manager is used to remove previously created Save Point. In order to restore Save Point, we need to provide Save Point ID, this is retrieved from the list:
List with Save Points is populated through Save Point Manager API and is exposed through Data Control:
We can test it now, sample application is enabled with ADF Security and we can login with redsam user:
Navigate to the next row and change Hire Date value - create new Save Point by providing its name and pressing Create Save Point button - newly created Save Point will appear in the list:
Login with another user - scott:
Save Point API is aware about ADF Security Context and it knows there are no yet Save Points created for scott user:
Let's create one after changing Salary value:
And one more after changing Hire Date value, now both Salary and Hire Date will be added to Save Point:
We can see in the DB table, there are three Save Points created. One for redsam user and two for scott - names are taken from ADF Security by Save Point API automatically:
Here is the prove for my earlier statement - Save Points are working based on PS_TXN passivation/activation. When Save Point is created - passivation happens. Later during Save Point restore, it activates data based on Save Point label from PS_TXN table:
You can get similar log displayed, by setting FINEST ADF log level for oracle.jbo package:
Let's login again with redsam user and try to restore previously created Save Point:
After login, data from DB is displayed as it should be:
Choose to restore previously created Save Point - Pending hire date change. This will reset current row and apply edited data for Hire Date:
User can continue with data change and transaction.
Login with the second user - scott:
Data is loaded from DB, there are two Save Points available in the list:
Select first one - to reset current row and bring edited Salary value:
Select second one - both Salary and Hire Date will be reset to edited values:
I can see ADF Controller Save Points very useful in combination with ADF BC for complex forms implementation, where we need to provide option to split or delay transaction. This is possible because of ADF BC - another plus for ADF BC in ADF.
Sample application - ADFTaskFlowSavePointApp.zip, is enabled with Save Points. To enable Save Points support, is enough to provide Data Source for the Save Points:
ADF application should create required table for Save Points automatically, same as PS_TXN table. Table for Save Points - ORADFCSAVPT. This table keeps information about current Save Points for every user:
ADF Task Flow, where we would enable Save Points is same as any other ADF Task Flow. There is only one extra activity created - Save Point Restore. This activity takes Save Point ID and restores it:
Save Point Restore activity takes Save Point ID to restore through property:
Looking from UI perspective, Save Point management can be implemented with options to create Save Point, display a list of previously created Save Points and restore one of the selected Save Points:
Create Save Point method is using Save Point Manager API to create new Save Point:
The same Save Point Manager is used to remove previously created Save Point. In order to restore Save Point, we need to provide Save Point ID, this is retrieved from the list:
List with Save Points is populated through Save Point Manager API and is exposed through Data Control:
We can test it now, sample application is enabled with ADF Security and we can login with redsam user:
Navigate to the next row and change Hire Date value - create new Save Point by providing its name and pressing Create Save Point button - newly created Save Point will appear in the list:
Login with another user - scott:
Save Point API is aware about ADF Security Context and it knows there are no yet Save Points created for scott user:
Let's create one after changing Salary value:
And one more after changing Hire Date value, now both Salary and Hire Date will be added to Save Point:
We can see in the DB table, there are three Save Points created. One for redsam user and two for scott - names are taken from ADF Security by Save Point API automatically:
Here is the prove for my earlier statement - Save Points are working based on PS_TXN passivation/activation. When Save Point is created - passivation happens. Later during Save Point restore, it activates data based on Save Point label from PS_TXN table:
You can get similar log displayed, by setting FINEST ADF log level for oracle.jbo package:
Let's login again with redsam user and try to restore previously created Save Point:
After login, data from DB is displayed as it should be:
Choose to restore previously created Save Point - Pending hire date change. This will reset current row and apply edited data for Hire Date:
User can continue with data change and transaction.
Login with the second user - scott:
Data is loaded from DB, there are two Save Points available in the list:
Select first one - to reset current row and bring edited Salary value:
Select second one - both Salary and Hire Date will be reset to edited values:
I can see ADF Controller Save Points very useful in combination with ADF BC for complex forms implementation, where we need to provide option to split or delay transaction. This is possible because of ADF BC - another plus for ADF BC in ADF.
Hi Andrejus,
ReplyDeleteThanks to upload the zip file.
On which version of Jdeveloper you develop this zip file.
This is 12c. But same functionality should work with any 11g version.
ReplyDeleteRegards,
Andrejus
I tried to work with your code but system giving the error at JAVAX.model.faces.Saveitem in ADFUtils.java class. i think jdeveloper unable to get this class file. could you please provide the class file which will support for 11.1.6 version.
ReplyDeleteADFUtils in the sample app is fully compatible with 11.1.1.6. You should import required libraries in your app.
ReplyDeleteRegards,
Andrejus
Hello Andrejus,
ReplyDeleteWonderfull article and thanks for the upload.
Can you please let know what is the lifetime of this Savepoint once created.
Thanks,
Krishna
Hi,
ReplyDeleteThere is timeout configured for Save Point, this controls lifetime.
Regards,
Andrejus