Tuesday, January 7, 2014

Simple Example for ADF Active Data Service

Active Data Service in ADF is very useful functionality, it allows to push data to the UI, without extra refresh/reload. However, due to its complexity, is not used too often. My goal is to provide as much as possible simple example for ADS use case in this post. In the future posts, I plan to post updated samples with more complex use case implementations.

ADS is configured in adf-config.xml file, here you can download complete sample application - LongRunningTaskPushApp.zip. There is active output text component, it displays number of open jobs and is refreshed by ADS:

Once we navigate to the Employees tab - Open jobs counter is reloaded:

Separate thread, where we generate new jobs is started when ADS is activated and is stopped automatically, when ADS is deactivated (when navigating away from page or closing browser):

Thread is stopped automatically, when browser is closed or navigating away to other page:

Active output text value is retrieved from managed bean method:

This managed bean is registered in session scope and is responsible to manage ADS lifecycle:

We can see that managed bean method is accessing binding and gets initial value from there - it comes from ADF BC attribute:

This relationship is defined in Page Definition - initial value is retrieved from ADF BC:

There is post construct method - we are setting up ADS model info, basically registering active output text component value to be reloaded automatically by push from ADS:

There are two standard methods from ADS model overridden to control ADS lifecycle start and stop events:

As you can see above - thread to push ADS changes is created in start method, automatically when ADS gets initialised after post construct method. Thread is stopped automatically, when ADS is deactivated (this happens when browser is closed or navigated to other page).

Active output text is reloaded by triggered method, where ADS event is generated - using registered active output text value:

When opening Employees tab, Open jobs counter is reloaded from resetData method, referenced from panel collection visible property:


Phai Vv said...

nices post. Thank you for keep it up

Andrejus Baranovskis said...


Anonymous said...


I am trying to extend the application and adding code to get BindingContext in AdsController triggerActiveDataUpdateEvent method. But BindingContext.getCurrent() is returning null. Can you please suggest what could me the issue. Currently i am only displaying the counter on jspx page with page definition file. The code itself is working fine.


Andrejus Baranovskis said...

I'm not sure if this would work with ADS, this was the reason in my sample app not to use Binding Context directly.


FrankD said...

What if i will need to do an executeQuery from the BindingContext or do something that is specified in the bindings ?

Andrejus Baranovskis said...

I don't think this is supported, this is why I was not using it directly in this sample - but publishing data from Model through push.