Wednesday, August 14, 2013

ADF Task Flow Transaction Management and ADF Libraries

I received a question from blog reader to check if ADF Task Flow transaction management still works when different Application Modules are coming from ADF libraries. Blog reader had a doubt it will not work. I did a test - it works well, so I would like to share this sample application with you as well.

Sample application - transaction_adf_libs_11g.zip is based on ADF library with Application Module - HrModule:


Reusable Application Module is packaged as ADF library and later imported into main application:


Main application contains second Application Module called HrMainModule:


At the end there are two Data Control entries available, one from local AM and another from imported one:


Both Data Control entries are registered in DataBindings.cpx file:


I have created one container wrapper task flow to launch target task flow with transaction management:


Target task flow contains one fragment (includes data from both Data Controls) and return activity (performs commit):


There will be always new transaction started on task flow entry, commit will be done on task flow level from return activity (see above):


From index page we can launch target task flow and initialise new transaction:


Here we edit data from the first Data Control in the left section:


Also data from the second Data Control in the right section:


Both changes will be saved automatically with single Save button click with ADF Task Flow transaction management. No matter if Data Controls are based on Application Modules from the same application or ADF libraries.

5 comments:

Rohan Walia said...

Very nice article Andrejus,

Also if the commit fails for any of the data control (local or ADF Lib) there will be no change in either of the DC. Both will be rolled back.

Thanks
Rohan

GopiNadh Simhadri said...

Hi
I have taken two AM
& i have taken data from two data controls on to the single page . How can we commit data of two DC on a single click

Siu Fai Ng said...

Hi Andrejus,

In my project, the system will call a backing bean to do the followings when user clicks Save button.
1. Update variables in backing bean
2. Insert a record to view object VO1 programmatically.
3. Update view object VO2 programmatically
4. Call commit function.

If exception thrown when save, the requirement is to prompt an meaningful error message and allow user to proceed and save again.

If error occur in step 3 or 4 in the Save process, the variables in backing bean are updated and the new record of VO1 is inserted. If user modifies data and clicks Save AGAIN, step 1 and 2 will be executed again !!! The result is not correct.

I cannot rollback the transaction, otherwise user will lose the input data.
Any suggestion?

Thanks.

Tony

Andrejus Baranovskis said...

Hi,

Of course it will be executed, you are calling same method again :)

You should implement some flag and check if 1 and 2 should be executed again based on previous operation completion.

Or try to use ADF Savepoint feature available in ADF Task Flow.

Andrejus

Siu Fai Ng said...

Hi Andrejus,

Thanks for your prompt reply.
Exception thrown in step 3 is just an example. Exception can be occurred in any step. It seems that my problem is not a rare case. The operation may consist of many steps and each step can throw exception for some reasons.

Does SavePoint uses many resources? or affect the performance?
Should we create SavePoint for every operations? because every operations can throw exception.

Many Thanks.

Tony