Skip to main content

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


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

Popular posts from this blog

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…