Sunday, April 25, 2010

Communicating Between ADF Regions Without Contextual Events Framework

There is a great video from Frank Nimphius - How-to use Contextual Events in ADF Region Interaction. Frank explains how you can trigger refresh and pass data between two independent regions using ADF Contextual Framework. While this works great, sometimes you may need something more simpler. I decided to explain another option - how to trigger refresh between two independent regions using ADF Task Flow parameters. Its just another option, you should use ADF Contextual Events Framework in most of the cases, but it always good to know alternatives. Described solution will work for the regions based on the shared Data Control.

Download sample application - RegionCommunicationPPR.zip. This sample is based on two ADF Regions - one brings Employees table data, another - Employes form data. User can select data in the table, form in the second ADF Region will be refreshed automatically and will show synchronized data.

Two ADF Regions:


How we can trigger second ADF Region refresh based on the changes from the first ADF Region? We will use ADF Task Flow parameters for the second ADF Region:


Its enough just to define parameter, no need to use - it is needed only to trigger refresh, the rest will be done automatically, because both regions are based on the same Data Control.

Next, we go to Page Definition file where both ADF Regions are declared:


Edit second ADF Region - employeesformflow1, its where we have declared Input Parameter. Make sure that Input Parameter value is not empty:


Here is a main trick of this post - Input Parameter of the second ADF Region should get value from EmployeeId attribute in the first ADF Region:


And second point - Refresh condition for the second ADF Region must be set to ifNeeded. This will make sure, that each time when input parameter value will be changed, it will trigger refresh for the second ADF Region and synchronize data:


Table selection from the first ADF Region triggers refresh in the second and shows the same row:


If you select another row - both table and form are synchronized again. Change Salary attribute value from 9000 to 10000:


Press Save button - changes will be stored and both ADF Regions are synchronized:

7 comments:

сестра said...

Hi Andrej,

Great Post as always! You are an inspiration to lot of us.

Cheers!

Andrejus Baranovskis said...

Thank you :)

Hasim said...

Hi ,

I will appreciate,if you can add one thing missing in this demo.

There is EmployeeId attribute in below binding and you have not described how to created that even though it is present in your demp.

com_redsamurai_view_employeesTablePageDef
+EmployeeId

Pretty nice article.

Hasim

vt said...

Hi,

I think you can creat it in your mainPageDef.xml model>binding or you can just bind your value to your ViewIterator it works fine on my appl

I m working on a pretty similar appl but i have more complexe TaskFlows in the 2 ADF regions.
I m encountering a diseagrable issue in the TaskFlow running in my 2nd region(form).

Looks like i can either make my TaskFlow works properly by letting the refresh option to "Default" but then i m not able to synchronise my form with my table. Is there a way to refresh without setting the option to "IfNeeded"?

Or i set the refresh option to "IfNeeded" then when i click to a button on the TaskFlow it doesnt launch the jsff page it supposed to.

Any hint on how i can solve this, ty.

Vincenzo

Toston said...

Great post, i've been searching for something like this.

My case its similar. y want to refresh a region (table) after a CreateInsert Form Region.

They are not the same datacontrol, but i need some "inputvalues" to refresh the next region (table).

Could you please give an idea?

Sorry for my (bad) english.

Toston said...

Thanks

satyabrata debta said...

Hi Andrejus,Thanks a lot for all of our inspiration.I have the same use case but i should not use data control and i want do the similar use case in programmatically without data control.i need your view on that.i will certainly appreciate Andrejus,Thanks a lot .


Thanks
Satya