|
Object #1: RSS Viewer (Click the headlines!) |
OpenAjaxExample Connecting an RSS Feed to an Output Window |
In this example, two independent objects interact with each other via the built-in OpenAjax Hub. The first object, an RSS viewer, registers a service and publishes a message to the hub whenever the user clicks on any of the links within the viewer. The second object, a webpage viewer, subscribes to the service and is called whenever the service publishes a message. When a message is received, the webpage viewer loads the page corresponding to the link clicked in the RSS viewer. |
![]() Click the headlines in the RSS VIEWER to automatically update the PAGE VIEWER |
Object #2: PAGE Viewer |
#TITLE# | ![]() |
OpenAjax-linked News Feed | ![]() |
KEY CONCEPTS:
|
How To Do It: |
TIP: You can use a special service instance ("xwinlib_dnd" ) of the OpenAjax hub to override the default drag and drop handler. Just include the following code in the page head and then subscribe to the service:top.xlib.openajax.initDragAndDrop( 1 ); |
Here's the code for the handler presented and discussed:
// params: e, msg, data var omsg, odata; // get extended msg and data objects // odata always uses extended format from within the object omsg = xlib.openajax.getMessage( msg ); odata = xlib.openajax.getData( data ); if ( omsg ) { // if extended msg, check message type if ( omsg.mtype & xlib.openajax.ID_MESSAGE ) { // set the iframe's src to the passed in url odata.win.iframe( ).src = omsg.msg; } } else { // if not extended message data // set the iframe's src to the passed in url odata.win.iframe( ).src = msg; }
In the example above, the handler is optimized for both standard and extended OpenAjax Hub communications. The extended msg and data objects consist of the following data elements:
Extended MESSAGE Object: omsg.sid omsg.mtype omsg.winname omsg.msg omsg.pt omsg.mouseButton omsg.key omsg.keyButton omsg.data omsg.lib |
Extended DATA Object: odata.winname odata.win odata.opts odata.data |