Pages

Thursday, October 31, 2013

ADF - Contextual Events Sample Application using Row Selection Listener

How we can use contextual events in the ADF Table Row Selection Listener.

About Contextual Events

Contextual events have two parts:
  • A publisher (or producer), such as a button that raises a named event, with or without a custom payload
  • A handler (or consumer) that listens for a specifically named event or a wildcard event, to process that event
Contextual events are very much useful when two different Application (ADF) are using or Webcenter inter portlet communication. When we are facing difficulty to pass parameters through TaskFlow or beans then contextual events are more useful.

We have two regions (TaskFlows), one with list of employees and second will display the employee details based on the user selection from employees list (we can wright this application without using contextual events also).
For this example i created a sample data model for Oracle HR database.
 


A simple UI application

If we use the ADF commandlink component tag have the feature to raise the contextual events directly.

Producer:
In this example i am going to override the rowselectionlistener and raise the contextual event.


To raise the event we need to create a custom event binding, this will raise the contextual event (Event Producer).

Make sure that we need to add Listener to raise the event(org.apache.myfaces.trinidad.event.SelectionListener) and Events and event with event name.

(Go to the Event binding in the structure window -> Right click-> inside the event bindings -> events.
 Then select the Events ->Right click -> event)

And we need to pass the payload value.


Consumer:

Fist we need to add our event handling method in page bindings.

In this example i added my Application module method directly, But we can create a java class and then convert that class in to data control and use those methods.
Then go to page bindings tab ->contextual events-> subscribers-> add

Provide the Event name and handler classe.
Note: we need to use same event name which we used int he Producer.


Ui screen shots.

Select the employee form the list it will raise the contractual event and employee view region will handle this event.

you can download the sample app.

0 comments:

Post a Comment