Wednesday, May 15, 2013

Save Point and Save Point Restore Activity Part1

Hi All ,

I did a sample POC which explained you what is use of save point restore activity in the task flow and also how to take snapshot of application and store into table base and later restore from back.

In developer guide following explanation is present about save point and save point restore activity.

Save Point :'A save point captures a snapshot of the Fusion web application at a specific instance.'

Save Point Restore Activity:'Save point restore enables the application to restore whatever was captured when the save point was originally created.'

Use Case:We have one page with two part where one part is used for link and second one is for dynamic region.Take a example that we have two link one is welcome link and another one is create employee link.
So if we toggle from one link to another link then data which we filled in employee form will automatically lost which we do not want.However we want to give privilege to user for restoring their lost data which still not into database.

Although there are two type of implementation approach for save point and they are

1-Implicit Save Point
2-Explicit Save Point

Here in this post i will explain explicit save point.

Ingredient for creating save point and restore save point :

1-One method for creating the save point.
2-Save Point Activity

Implementation of Explicit save point:

1-Creation of model Layer
2-Creation of View Layer
3-Configuration of data base to save save point to table
4-Creation of save point
5-Adding restore save point activity on task flow
6-Removing restore save point data from table

1-Creation of model Layer: I just created employee Entity object,View Object and added View Object into Application module.


2-Creation of View Layer :Create one bounded task flow which contains all save point related information and also view pages .

3-Configuration of data base to save save point to table: By default jdevelope does not configure target location for saving save point value into data base.Therefore we need to do configuration.
Step are following

1-Go to the Application resources section
2-Open adf-config.xml file
3-Click on controller section
4-Under save point add your data base connection it can be jndi name

5-After adding entry it will add following metadata code inside it file

<adf-controller-config xmlns="">

Data base configuration has been finished.

4-Creation of save point : For creating save point you need to first identity where you want to take the snapshot of application.In my case i have one button which call save.And it will use for create the save point and take the snapshot.

You have call following method to take the snapshot of application however there are two way to call this method.

java.lang.String createSavePoint()
Creates a save point with no custom attributes. The save point will be automatically removed when a top level bounded task flow on the stack completes execution. In order to ensure successful save point creation, all entries in the page flow scope must be serializable.

Returns:id of the save point that was created, or null if the save point was not successfully created.

1-You can call using expression language code

2-You can also call using java code and i have doing in my application using java code and code are

    public String saveTaskFlow() {
        ControllerContext controllerContext = ControllerContext.getInstance();
        String savePointId = null;
        if (controllerContext != null) {
            SavePointManager savePointManager =
            if (savePointManager != null) {
                //creating the save point
                savePointId = savePointManager.createSavePoint();
                //putting the save point id into session scope
        return null;

5-Adding restore save point activity on task flow : You need to drag and drop save point restore activity into task flow to restoring the application. And you need to provide correct save point it. In my case it is available in session scope.Therefore i am passing it from session scope.

6-Removing restore save point data from table: In task flow there is one property call save point restore finalize which take method as value and it will called method after restoring snapshot.

Here you can get the hook point and you can write code which execute after restoring the save point.

    public void removeId() {
        String savePointId =
        if (savePointId != null) {
            ControllerContext controllerContext =
            if (controllerContext != null) {
                SavePointManager savePointManager =
                if (savePointManager != null) {

Here i am removing save point snapshot from table using savePointManager.removeSavePoint(savePointId) ethod which except savePointId. and also i am removing session id from the scope which mean user can not restore again.You change logic base on your business requirement.

Data base structure is following which will store snapshot value's.
Table Name is :ORADFCSAVPT

You can download sample at following link: