Wednesday, February 24, 2010

Integration in Oracle ADF with ADF Task Flows and Dynamic Regions

In my last post I described Dynamic Dashboard component, it allows to integrate separate applications using ADF regions. If we have fragments, we can drag and drop them easily into dashboard component as regions. You can read more about how to integrate ADF applications from my integration post series. Depending on requirements, you may want to implement dynamic regions and integrate your ADF applications into single main application. Well, I was thinking about this before, but it was not working. Until one fellow developer from sunny South Africa didn't logged it (thanks to him) on Oracle Metalink (SR 3-1354209241), and got reply. Well, I will describe today how you can use Dynamic Regions for ADF applications integration.

Download sample application - ADFIntegrationRegions.zip. This sample implements four different separate applications, all of them contain JSF Fragments and ADF Task Flows. Also there is one main application, where all four are integrated through ADF Regions included from ADF Libraries.
While talking with developers, I noticed often people don't understand how they should include ADF JAR libraries into project. So, if we have a list of libraries in Resource Catalog:


It is enough just to right click available library and choose Add To Project option (of course you should select ViewController project before). Or you can simply drag and drop ADF Task Flow into JSPX page and choose Create Dynamic Region option. Once libraries will be added, you should see ADF Library entry under imported libraries. In this example, ADF Library contains four JAR's:


Main application doesn't have any Model implementation, however because I'm using ADF connection for database, I must enable it anyway. Just go to Model Project Properties and enable it in Business Components section:


Ok, now let's talk about main thing - how to make it work with Dynamic Regions. When you drag and drop ADF Task Flow and create Dynamic Region, it asks you to create managed bean, where Dynamic Regions will be activated:


And here is main problem - it creates this bean in BackingBean scope. However, Dynamic Regions are not working well in BackingBean scope (check Oracle Metalink SR mentioned above):


In order to make it work, Managed Bean must be declared in Page Flow scope:


Yes, thats simple - just change generated bean scope and it starts to work. Integration itself works pretty simple, we have one region declared on the page:


This region is initialized dynamically from Managed Bean (Page Flow scope) and populated with Dynamic Regions based on user menu selection:


We have listed in the menu, four regions included from separate applications:


If Departments will be selected, Dynamic Region for Departments is opened:


Same works for Jobs:

14 comments:

HongMing said...

Hi Andrejus

When I change dynamic region bean to pageflow, I have below error.

oracle.adf.controller.ControllerException: ADFC-06001: TaskFlowId '${pageFlowScope.DynamicRegBean.dynamicTaskFlowId}' is invalid.

Please advise what cause it

Thanks

HM

Ricardo said...

Andrejus Hello. We are watching your example. I have a question about dynamic regions. As I can send an operation, such a task flow CREATEINSERT in particular? I want to avoid putting a button on the page of the fragment with this operation.
Thank you very much. Regards

Andrejus Baranovskis said...

Hi Ricardo,

Yes, you can implement this operation as Method Call, it should be invoked before opening fragment in ADF Task Flow. For example, this Method Call can be Default Activity.

Regards,
Andrejus

Anonymous said...

Hello my friend,

How would u have all imported apps use one connection ir other example has the model being imported but here the apps have been defined....i am trying to best way to modulize huge app but still use one connection with subversion.

Anonymous said...

Any comment on the ADFC-06001: error. We are seeing the same thing.

Andrejus Baranovskis said...

Hi,

Make sure declare this bean in Task Flows as pageFlowScope as well.

Andrejus

vikas said...

Hi HongMing,

go to the page jspax on which you dragged and drop the dynamic task flow and change it to ${bindings.DynamicRegBean.dynamicTaskFlowId}'

and more importtant thing go to the page defination of this file where you will fine like taskFlowId="${somescope.somepackage.dynamicTaskFlowId}" and change somescope to pageFlowScope

Anonymous said...

I am trying to implement same dynamic panel dashboard in my application. But my code doesn't like the property "key" on af:declarativeComponent as shown below. Did i miss anything from the example.








ElGueuzifié said...

Hi Andrejus

Thank you for this post.
But if i have a task flow with parameters, how can i programmatically pass the parameters ?

Ghazi

Andrejus Baranovskis said...

You can do it, I think this is documented in ADF developer guide available online.

Andrejus

ElGueuzifié said...

I used this code to get the task flow from the executables in the pageDef :

BindingContext bindingCtx = BindingContext.getCurrent();
DCBindingContainer dcbCon = (DCBindingContainer)bindingCtx.getCurrentBindingsEntry();
oracle.adf.controller.internal.binding.DCTaskFlowBinding taskFlow = (oracle.adf.controller.internal.binding.DCTaskFlowBinding)dcbCon.findExecutableBinding(taskFlowName);

But the method "getInputParameterValues()" in "DCTaskFlowBinding" is protected

Ghazi

Andrejus Baranovskis said...

You should not use "internal" ADF BC classes.

Andrejus

ElGueuzifié said...

My problem is : if one of the task flows in the ADF shared libraries needs parameters, how can I pass the values of those parameters in the main application and of corse keep using dynamic task flow id ?
is it possible ?

Thanks.

Ghazi

Andrejus Baranovskis said...

Just google for ADF Dynamic Task Flow and passing parameters - I'm sure you will find answer with source code.

Andrejus