Tales from the Evil Empire

Bertrand Le Roy's blog

News

Ads Via DevMavens

ASP.NET AJAX UpdatePanel Control: Add Ajax interactivity to your ASP.NET 2.0 web pages

Add to Technorati Favorites

Blogs I read

My other stuff

OpenAjax InteropFest 1.0: Microsoft's entry

Yesterday I got to write our entry in OpenAjax's InteropFest. The goal of this event is to demonstrate how different Ajax libraries can be parts of the OpenAjax ecosystem and interact with each other through the OpenAjax hub. The currently central feature of the hub is to expose a publish/subscribe message bus so that both producers and consumers of events can speak through a third party that is neutral to specific Ajax implementations.

The OpenAjax Alliance provides a template for demo applications that shows a live data source feeding fake stock quotes through the hub to a visual component that then renders them.

I've chosen to modify the live data source to be a Microsoft Ajax-style component. The visual component would not have been as interesting because it's really the application that is a consumer of events. The visual component itself doesn't strictly speaking communicate with the hub, the application does (through a trivial API call) and then transmits the results to the component for rendering. In other words, the data source is a lot more interesting because it exposes the event, and if it is a Microsoft Ajax component, it will use the Microsoft Ajax event pattern, which is quite different from the OpenAjax event pattern.

I did refactor the consuming part of the application quite heavily, but that was more to understand it than anything and it's not the essential part of our entry.

To achieve the mapping from Microsoft Ajax events to OpenAjax messages, I've written the following simple helper:

Type.registerNamespace("Sys.OpenAjax");

Sys.OpenAjax._Helper = function() {
}
Sys.OpenAjax._Helper.prototype = {
    mapEventToMessage:
function(owner, eventName, messageName, publisherDataMapper) {
var handler = function(sender, args) { OpenAjax.hub.publish(
messageName,
publisherDataMapper ?
publisherDataMapper(sender, args) : null); } owner["add_" + eventName](handler); return handler; }, unmapEvent:
function(owner, eventName, map) { owner["remove_" + eventName](map); } } Sys.OpenAjax._Helper.registerClass("Sys.OpenAjax._Helper"); Sys.OpenAjax.Helper = new Sys.OpenAjax._Helper();

The application code can use that new API to map the events of any Microsoft Ajax component to become publishers of OpenAjax messages without any necessity for the component to contain any code specific to OpenAjax, let alone know about it. In other words, the component implementation remains completely decoupled from OpenAjax and it's the application that makes the connection.

The application maps the quoteChanged event to the org.openajax.interopfest10.datagen.stockpriceupdate OpenAjax message like this:

Sys.OpenAjax.Helper.mapEventToMessage(
    corpList, "quoteChanged",
    "org.openajax.interopfest10.datagen.stockpriceupdate",
    function (sender, args) {
        var quote = args.get_quote();
        return {
            tickerName: quote.symbol,
            corpName: quote.name,
            price: quote.price
        };
    }
);

From this moment on, all quoteChanged events will be published on the hub. An interesting thing to note is the use of an optional function that maps the Microsoft Ajax event argument to the expected OpenAjax data payload.

Brad Abrams kindly hosts the demo on his personal website for the moment:
http://brad_abrams.members.winisp.net/Projects/OpenAjax/index.html

The source code can be downloaded by clicking here.

Comments

Techy News Blog » OpenAjax InteropFest 1.0: Microsoft's entry said:

Pingback from  Techy News Blog » OpenAjax InteropFest 1.0: Microsoft's entry

# September 21, 2007 5:04 PM

Microsoft News Aggregator » OpenAjax InteropFest 1.0: Microsoft's entry said:

Pingback from  Microsoft News Aggregator » OpenAjax InteropFest 1.0: Microsoft's entry

# September 22, 2007 1:07 AM

OpenAjax InteropFest 1.0: Microsoft's entry : Celebrity News Corner said:

Pingback from  OpenAjax InteropFest 1.0: Microsoft's entry : Celebrity News Corner

# September 22, 2007 3:32 AM

Brad Abrams said:

Recently Bertrand posted OpenAjax InteropFest 1.0: Microsoft's entry . The OpenAjax's InteropFest 's

# September 23, 2007 10:11 PM

MSDN Blog Postings » Microsoft Passes the OpenAjax InteropFest Test said:

Pingback from  MSDN Blog Postings  » Microsoft Passes the OpenAjax InteropFest Test

# September 23, 2007 11:23 PM

Noticias externas said:

Recently Bertrand posted OpenAjax InteropFest 1.0: Microsoft's entry . The OpenAjax's InteropFest

# September 24, 2007 1:26 AM

Bertrand Le Roy said:

Microsoft joins several other companies and open-source projects in meeting OpenAjax guidelines.

Microsoft has passed the OpenAjax Alliance's suite of interoperability tests to prove that its software can interoperate with other parts of the OpenAjax ecosystem.

# September 24, 2007 1:39 PM

Techy News Blog » Getting AJAX defined… said:

Pingback from  Techy News Blog » Getting AJAX defined…

# September 26, 2007 4:54 AM

MSDN Blog Postings » Getting AJAX defined... said:

Pingback from  MSDN Blog Postings  » Getting AJAX defined...

# September 26, 2007 5:25 AM

voip » Getting AJAX defined... said:

Pingback from  voip » Getting AJAX defined...

# September 26, 2007 11:40 AM

.net DEvHammer said:

Via Christopher Steen : Microsoft Passes the OpenAjax InteropFest Test Recently Bertrand posted OpenAjax

# September 27, 2007 10:42 AM

The ServerSide Interoperability Blog » Sample of Ajax interop said:

Pingback from  The ServerSide Interoperability Blog » Sample of Ajax interop

# September 28, 2007 4:08 PM

Programming said:

Recently Bertrand posted OpenAjax InteropFest 1.0: Microsoft's entry . The OpenAjax's InteropFest

# September 29, 2007 7:39 PM

Gaidar Magdanurov said:

Коллеги Брэд и Бертранд написали о возможности использования Microsoft Ajax для работы с сообщениями OpenAjax.

# October 2, 2007 9:58 AM

Noticias externas said:

Коллеги Брэд и Бертранд написали о возможности использования Microsoft Ajax для работы с сообщениями

# October 2, 2007 10:16 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)