Skip to content
June 5, 2014 / Amaro Bica

How to pass complex payload in programmatic Contextual Event launch

In Oracle ADF applications, sometimes we need to trigger Contextual Events programmatically on action listeners or another kind of listeners because some ADF Faces components don’t have out of the box Contextual Event configuration through Property Inspector. Rich Command Menu Items, Rich Command Navigation Items and Rich Command Buttons are some examples of these components.
In most of the cases we want to pass a complex payload with information about the Contextual Event. How to pass it?


The solution is to pass a class that represents the payload, instantiate it on launching the event and casting to it on handling. In this tutorial I created a page with two regions:

  • a top region that contains a menu that launches the event with information about the button pressed and a value of an inputText
  • a bottom region that catches the event updating an outputText.

Download here .

Payload class

First you have to create a Java class representing the payload. In the provided example, it’s being passed a color and a username:

package pt.linkconsulting.cepayload.payload;

public class MenuEventPayload {

    private String color;

    private String username;

    public MenuEventPayload() {



    public MenuEventPayload(String color, String username) {


        this.color = color;

        this.username = username;


    // getters and setters




Before launching the Contextual Event, you should publish it on publisher’s page definitions as usual like in the following example:


Then in the event listener method of the publisher side you must import that class and include the following code:

//get the eventBinding and its dispatcher
JUEventBinding eventBinding =

EventDispatcher eventDispatcher =

// create the payload
MenuEventPayload menuEventPayload =
    new MenuEventPayload(color, username);

eventDispatcher.queueEvent(eventBinding, menuEventPayload);


In the subscriber side, do the usual job to handle Contextual Events, except in the last step.
Create a Data Control from the class with the method that will handle the event:


Register the method in the bindings:


Register the in page definition’s event map:


And finally you must import your payload class and cast the argument to it:

public void handleEvent(Object payload) {

    MenuEventPayload menuEventPayload = (MenuEventPayload) payload;

    String color = menuEventPayload.getColor();

    String username = menuEventPayload.getUsername();

    // use these parameters to update your subscriber region



Now you are ready to run your app.


34 Using Contextual Events, Oracle® Fusion Middleware Fusion Developer’s Guide for Oracle Application Development Framework 11g Release 2 (


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: