A glance at the implementation
1. You can create your own event dispatcher (from scratch) by implementing oracle.adf.model.events.EventDispatcher. Alternatively, if you want to override specific behavior alone then consider sub classing oracle.adf.model.binding.events.EventDispatcherImpl 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="http://xmlns.oracle.com/adfm/application" version="126.96.36.199.60" id="DataBindings" SeparateXMLFiles="false" Package="view" ClientType="Generic" EventDispatcher="view.extension.CustomEventDispatcherImpl">
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.