Monday, April 7, 2008

Automatically save transactions with ADF Taskflow

ADF Taskflow has the option to automatically save all the transactions in bounded critical taskflows. This is called an implicit save. This save action happens when there is a timeout or when the user closes the browser and the transaction is still open. In this blog entry I will show what you have to do to enable this and I will show how you can restore it with a select one choice with the saved transaction. My previous blog give an example for an explicit save. With an explicit save the user decide to save the transaction so he or she can continu the transaction later.
The first step is to edit the adf-config.xml to enable automatically save in bounded taskflows.

<?xml version="1.0" encoding="windows-1252" ?>
<adf-config xmlns=""
<sec:adf-config-child xmlns="">
<CredentialStoreContext credentialStoreClass=""
<sec:JaasSecurityContext initialContextFactoryClass=""
<adfc-controller-config xmlns="">

Now we can create two taskflows the first is unboundend taskflow with the restore savepoint functionality and the second is the bounded taskflow where ADf will save the open transactions. The unbounded taskflow looks like this. Here you see I call the bounded taskflow and I added a savepoint restore component which restores the session with this variable #{pageFlowScope.saveId}. I added also ADF security with the wizard so I only save and restore my own sessions.

The unbounded taskflow looks like this. It is very important to set critical on true else your transactions won't be saved.

The bounded taskflow jsf page has a submit button else the webapp doesn't detect the changes to the record.

We are ready to add the restore functionality to the main page in the unbounded taskflow. For this I use a selectOneChoice with his own saved transactions, I also added a clear transactions button.

<af:panelGroupLayout layout="horizontal">
<af:selectOneChoice label="Savepoints" value="#{pageFlowScope.saveId}">
<f:selectItems value="#{savepoints.savepoints}"/>
<af:commandButton text="Restore" action="restore"/>
<af:commandButton text="Clear savepoints" action="#{savepoints.clearSavepoints}"/>

I had to use a session bean to fill the selectonechoice, It didn't work with #{controllerContext.savePointManager.listSavePointIds}.

package nl.ordina.bean;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;
import oracle.adf.controller.ControllerContext;
import oracle.adf.controller.savepoint.SavePointAttributes;
import oracle.adf.controller.savepoint.SavePointManager;

public class Savepoint {

private ControllerContext cc;
private SavePointManager save;

public Savepoint() {
cc = ControllerContext.getInstance();
save = cc.getSavePointManager();

public List getSavepoints()
List options;
options = new ArrayList();
List saves = save.listSavePointIds();
SelectItem option;
int size = saves.size();
for ( int i = 0 ; i < saves.size() ; i++) {
SavePointAttributes att = save.getSavePointAttributes(saves.get(i));
option = new SelectItem(saves.get(i),saves.get(i)+att.getName());
return options;
public String clearSavepoints() {
return null;

Now we are ready to save and restore transactions.
Here you can download the example project Make sure you re-enable the security on the main pagedef else your system-jazn-data.xml isn't updated with the needed permissions.


  1. hi
    i have tried the example for the Save for later functionality in ADF.
    but i am getting following error,
    Can you please help me?

  2. Hi,

    I don't see the error, if it is a xml then please convert it with a html encoder.

    thanks Edwin

  3. sorry i forgot to paste.
    what did, i just deployed your application and when i ran the update.jspx page and i did the some chages in textboxes values on page. And when clicked on back button
    I am getting following error

    oracle.adf.controller.ControllerException: ADFC-00008: The ADF Controller is unable to find DataControlFrame for a task flow.
    at oracle.adfinternal.controller.util.Utils.createAndLogControllerException(
    at oracle.adfinternal.controller.util.model.DCFrameImpl.makeCurrent(
    at oracle.adfinternal.controller.state.ViewPortContextImpl.makeCurrent(

  4. Ok,

    I will check this in the new JDev. I will keep you updated


  5. Hi Edwin,
    can you please reply to my thread,

  6. Hi
    I updated the sample to JDev 11g R1 PS2 ( download it again ) and everything is working fine on my laptop ( also the back button ), just log in as weblogic and edit an emp , submit and close the browser
    open the application again and restore the session.

    thanks Edwin

  7. And can you check if you have the following table oradfcsavpt in your db schema

    and if it contains records

  8. Hi,
    This post helped me a lot thanks for the same.

    I have one doubt.. How can we restore the savepoint on page load,instead of restore button?

    I have been trying to do the same but was unable to do it.can you please help me.

  9. Hi,

    you can do this in the Task Flow. as first action.

  10. Hi Edwin,

    I can see savepoint in database but when I try to select the one and click on restore I am getting oracle.jbo.AlreadyLockedException: JBO-26030: Failed to lock the record, another user holds the lock.

    now if I run the application again it works fine.
    can you give me any idea on this?

  11. Hi nikhil,
    Can you please check lock mode? whether is it optimistc or pessimistic.
    try to keep lock as optimistic.

  12. Thanks Kiran. Issue resolved by checking checkbox for optmistic mode in adf-config.xml