Skip to main content

Building a custom event dispatcher for Contextual Events

ADF lets you to create custom event dispatcher to override the default one to provide custom behaviors. In this post, I'm sharing a simple example built using a custom event dispatcher. Please refer this topic 28.7.6 How to Register a Custom Event Dispatcher in Fusion Developer's Guide to learn more about this topic.

A glance at the implementation

1. You can create your own event dispatcher (from scratch) by implementing Alternatively, if you want to override specific behavior alone then consider sub classing or its base class - AbstractEventDispatcher.

2. Next step is to register the custom event dispatcher in the Databindings.cpx file
<?xml version="1.0" encoding="UTF-8" ?>
<Application xmlns=""
  version="" id="DataBindings" SeparateXMLFiles="false"
  Package="view" ClientType="Generic"

Cool...The basic infrastructure to use your custom event dispatcher is in place now. enjoy !

You can download the sample workspace from here.
[Runs with Oracle JDeveloper 11g R1 PS2 + HR Schema]

How to run this sample?

This sample is configured to use view.extension.CustomEventDispatcherImpl class as event dispatcher. The CustomEventDispatcherImpl class check for the event payload type and if payload is 'instance of' view.extension.OriginAwarePayLoad, then decorates the payload by adding the producer name. Please note that, this is just a simple example to illustrate the custom event dispatcher. You can have more smart implementations (based on your use cases) and do it in your own way!

1. Run the main.jspx
2. Click on the Command Button which generates contextual event. Here the event payload is defined as a custom object, sub classed from a view.extension.OriginAwarePayLoad.
3. Control comes to the custom event dispatcher - CustomEventDispatcherImpl . This class overrides invokeEvent(...) to add 'event producer id' to the pay load.
4. Finally, event handler method (defined for the subscriber) receives this decorated payload and the same is used for further execution.


Popular posts from this blog

Happy New Year 2018 !

We can't go back and change the beginning, but we always can start where we are and change the ending. Believe in yourself and you will be unstoppable!

Wishing you and your family a very happy new year 2018 !!!

How to set Bind Variable Values at runtime ?

In this post I'm sharing a couple of approaches for programmatically setting bind variables values at run time. This post is an attempt to explain 'When to use what ?'[ In case if you are familiar with 'Bind Variables' in ADF BC, please refer Section 5.10, Working with Bind Variables in Fusion Developer's Guide ]

1. Set the Bind Variable value using RowSet::setNamedWhereClauseParam(...)

You can use use the setNamedWhereClauseParam(...) method on the ViewObject interface (which extends oracle.jbo.RowSet) to set the value for bind variables. Please note this sets the value on default RowSet. In other words, this doesn't have any effect on the secondary RowSets that you/system generates.
ViewObject vo = am.findViewObject("EmployeesView1"); vo.setNamedWhereClauseParam("bindVarDeptId", new Number(10)); vo.executeQuery();
2. Set the Bind Variable value using ViewObject's VariableValueManager::setVariableValue(...)

VariableValueManager Ma…