ADF Tutorial: How to refresh an LOV after Commit operation? Ah! Using contextual events.

This time, we are going to show an easy way to refresh an LOV that needs to be updated just when a Commit is done on the based LOV’s View Object. This use case, also will show how to accomplish the task by using a powerful ADF Feature; Contextual Events.

In our example, we will be looking at a very simple SearchVO that has Region LOV based on the RegionVO. The page is using a default template with 2 taskflows in it. The first one is a Region’s form to add a new Region, the second one is a Search Form that uses a Region’s based LOV. This is how it looks;


Our RegionId has the following default values;


If we add a new region without implementing the solution, it wont be shown after the commit is performed; we will need to close the browser and invoke the application again so it displays the new added region. So what is the solution? Yes we have already said it, contextual events;

So how is the deal? Let’s try to explain it in plane English first. The taskflow A (region form) wants to let know taskflow B (search form) that needs to update the region lov because a new item has been commited to database. So this means that taskflow A needs to raise an event and taskflow B needs to consume it performing the Execute operation to refresh the iterator.

So this is how it looks the contextual event in our Commit Operation in taskflow A; You can right click to Commit operation in the structure view, add events -> add event -> specify the name of your event.


Now, we need to add to our taskflow B the operation we want to execute when the notifyCommit event has been raised. We go to our taskflow B region’s page definition and add the Execute method. Now, according to your implementation this step might change, however, since our RegionLOV is coming from a SearchVO that has a ViewAccessor (RegionVO) for the LOV, we need to update that specific iterator; Regions;


So, all what is left is to set up the logic for the Execute method to be invoked when the notifyCommit event has been raised. Since in this case we have 2 BTF rendered as a region in a parent page (Home), we need to specify it in the Home’s bindings page, this is going to homePageDefinition -> ContextualEvents tab -> Add new Subscriber -> Select the event notifyCommit;


And select the Execute operation as the subscriber;


If we rerun the application, we are able to see the new region in the LOV just after it has been commited to DB.

Leave a comment

Your email address will not be published.

Social Media

Stay up-to-date with our latest ADF and related technical posts via your favourite social network services.