Data Controls Implementation Guide

Data Controls Implementation Guide

Messaging

Messaging

You need to establish connectivity from a component embedded in iFrame to the embedding application, as the embedded component contains action buttons that trigger some logic in the external application. The connectivity is implemented as messaging by using the window.postMessage JavaScript function, which allows cross-window or cross-domain messaging.
Messaging is supported by browsers such as Safari 4, Firefox 3, and Internet Explorer 8. To use messaging for Internet Explorer 7, additional configuration steps are required. The Duplicate Prevention control sends events to the embedding application by using postmessage plugin. Duplicate Prevention component sends messages in a predefined format, which the embedding application needs to handle. Each messaging event is a JavaScript object with an action field identifying the type of event.
The Duplicate Prevention component generates the following types of events:
ON_LOAD
The ON_LOAD event is generated when search for duplicates and rendering of the component is completed. This event has a
duplicatesFound
field that provides an indication if matched records are found.
ON_OPEN
The ON_OPEN event is generated when a user clicks the Open button. This event has an
id
field that identifies selected matched records. It contains the value of the PKEY_SRC_OBJECT field of XREF record from the target Source System (primary key value from the source system). Code handling this event can use this
id
to find and open matched records in the embedding application.
ON_IMPORT
The ON_IMPORT event is generated when a user clicks the Import button. This event has a
record
field that contains data of selected matched records serialized into the string in JSON format. Code handling this event can use a
record
data to create new records in the embedding application.
The Duplicate Prevention control uses the
idd_pmc_event
string as the postmessage type of event, and this string should be used to register handler for events generated by the control.
The following is a sample HTML page embedding a Duplicate Prevention control that shows you how to register a handler for events generated by the component:
<html> <head> <!-- include postmessage JavaScript plugin --> <script type="text/javascript" src="http://postmessage.freebaseapps.com/postmessage.js"></script> <script type="text/javascript"> // function handling events function handleEvent(data) { switch(data.action) { case 'ON_LOAD': // handle ON_LOAD event break; case 'ON_IMPORT': // handle ON_IMPORT event break; case 'ON_OPEN': // handle ON_OPEN event break; } } // register function 'handleEvent' as handler for events generated by Duplicate Prevention component function bindHandler() { pm.bind("idd_pmc_event", function(data) { handleEvent(data); }); } </script> </head> <!-- register event handler from onload event --> <body onload='bindHandler();'> <!-- embed Duplicate Prevent component --> <iframe src="http://<host>:<port>/bdd/bdc/<component name>/sa:<subject area>,<match parameters>/proactive_match/component.jsf></iframe> </body> </html>

0 COMMENTS

We’d like to hear from you!