This topic provides an example of how you can use broadcast events to allow widgets and gadgets to communicate with each other.
When working with gadgets and widgets together on a mashup page, sometimes you may want them to communicate through broadcast events. For example, you may want gadgets that publish broadcast events to be able to publish those events to other gadgets and widgets on the page. Likewise, you may want gadgets that receive events to be able to receive events from other gadgets or widgets on the page. In order to support this communication between gadget and gadget as well as between gadget and widget, you must invoke an API from the built-in Shindig container. This manual coding is necessary because gadgets currently do not support wiring through eventing.
Mashup Center ships with two default OpenSocial gadgets that you can use as examples of how to invoke the API required to achieve support for eventing. One gadget supports a publish broadcast event, and the other gadget supports a subscribe broadcast event. For an example of how these two gadgets use the API for eventing, see subscribeGadget.xml and publishGadget.xml in the Mashup_Center_install_root/mm_profile/installedApps/<serverCellNode>/gadgetsDemo.ear/gadgetsDemo.war folder on the Mashup Center server. These two files show you how to use an com.ibm.mashups.opensocial.anystring ID to publish and subscribe to events.