Wednesday, February 22, 2012

Programmatically Starting Transaction in a Task Flow

Sometimes static transaction settings for a task flow may not be really flexible enough to meet your use case requirements. For instance, based on the  invocation context(based on the caller) a task flow may need to either start new transaction or skip the transaction altogether. A simple example illustrating the programmatic transaction creation is attached in the post. Take a look at the  dept-task-flow-definition in the example which uses 'TxnInitializer' method for programmatically starting new transaction based on the input parameter(Transaction) value set by the caller. Here is the code snippet :


public void beginNewTransaction() {
BindingContext context  = BindingContext.getCurrent();
String dataControlFrameName  = context.getCurrentDataControlFrame();
DataControlFrame  dcFrame  = context.findDataControlFrame(dataControlFrameName );
dcFrame.beginTransaction(new TransactionProperties());
}



Download

You can download the sample workspace from here.
1. Run main.jsf.
2. The dept-task-flow-definition added to main page starts transaction programmatically based on the  Transaction'  parameter value specified in the task flow binding.
[Runs with Oracle JDeveloper 11.1.2.1.0 (11g R2PS1) + HR Schema]


Learn More ...

There are a lot more points like this. If  you are curious to learn the internals of the ADF Business Components and ADF Binding Layer,  the following book is for you - Oracle ADF Real World Developer’s Guide.
More details about this book can be found in this post- http://jobinesh.blogspot.in/2012/07/pre-order-your-copy-of-oracle-adf-real.html


2 comments:

cpierres said...

Hello,
I've already bought your book (pre-order)... but when it will be available please ?
Thanks,

Jobinesh said...

Thanks for ordering my book. The book is released yesterday, More details here - http://jobinesh.blogspot.in/2012/10/oracle-adf-real-world-developers-guide.html