Wednesday, September 10, 2014

ADF BC View Object Change Notification Listener

ADF BC allows to define triggers to listen for row changes on VO level. We can listen for row updates, inserts and deletes. This can be useful, if you would like to invoke specific audit method or call custom methods to populate dependent transient VO's with updated data.

To enable such triggers, you must add a listener for VO, this can be done during VO creation from standard create method:

ADF BC API methods, such as rowInserted, rowUpdated, rowDeleted can be overridden. These method will be invoked automatically by the framework, when change happens. You can check rowUpdated method, I'm getting changed attribute names (actually it calls this method for each change separately). Getting changed value from current row, also retrieving posted value:

CountryId attribute is set to be refreshed on update/insert, this means change event should be triggered as well, even we would not change this attribute directly:

We should do a test now. Change two attributes - Street Address and State Province, press Save button:

Method rowUpdated is invoked two times, first time for Street Address change (method is invoked before data is posted to DB):

Second time is invoked for State Province change. This means, we can't get all changes in single call, each change is logged separately. It would be much more useful to get all changes in the current row through a single call:

After data is posted, Country ID attribute is updated - this changed is tracked successfully:

Let's try to create new row:

Method rowInserted is invoked, however it doesn't get data yet - key is Null:

Right after rowInserted event, rowUpdated event is called in the same transaction - we can access data from that method. This means rowUpdated generally is more reliable:

Try to remove a record:

Method rowDeleted will be invoked, row data is accessed and key is printed correctly:

Download sample application -


oracleappsnotes said...

Does this work on a VO which is not based on an EO? Lets say, I have a VO, VO1 based on a query which is updateable. Based on the changes made on this VO, I will programatically insert, update or delete rows in another VO, VO2.
So can I use the rowInserted, rowUpdated, rowDeleted methods on VO1.

Andrejus Baranovskis said...

Yes, this works on readonly VO as well.


oracleappsnotes said...

Thanks Andrejus!

David Gress said...

Hi Andrejus,

You mentioned: we can't get all changes in single call.
Would if be possible to set a logical to indicate the row has been updated and then use that as a basis for starting some process?