Arun Gupta, Miles to go ...

Arun Gupta is a technology enthusiast, a passionate runner, and a community guy who works for Sun Microsystems.
« Previous day (May 20, 2007) | Main | Next day (May 22, 2007) »

http://blogs.sun.com/arungupta/date/20070521 Monday May 21, 2007

Week 14 Mileage

Mon: Rest
Tue: 3.5 miles
Wed: 3.5 miles
Thu: 3.5 miles
Fri: 10 miles Bike
Sat: 7 miles
Sun: Rest

Traveling spoiled my long run this weekend but I plan to do a good one coming weekend.

Couple of good reads this time ...

  • Eat like Lance - Learn to fine-tune your diet from the man who coached Lance Armstrong to 7 consecutive Tour-de-France wins.
  • Runner's Pantry - 10 canned foods that should be in every runner's pantry.

Technorati: running fitness runninglog

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

jMaki publish/subscribe and debugging

So far you've been playing with jMaki and created some Web and/or Rails applications. Let's say you've gone a step ahead and some widgets in your application use jMaki's publish/subscribe mechanism to talk with each other. Some jMaki widgets, such as Menu and Dynamic Container are pre-configured to publish and subscribe to the same topic. So if you develop a simple menu-based application then it'll work without adding any glue code. Another example is Yahoo GeoCoder publishing and Yahoo Maps and Google Maps subscribing. This allows you to drop all three widgets together on the same page and if you enter a city and state in GeoCoder, the coordinates will show up in both the maps. So far so good, but what if you are writing custom publish and subscribe code and it's not working. Lets see how we can debug that.

Let's say there is a Yahoo Calendar and Data Table widget in the page. The Data Table displays stock tickers by pulling the data from quote servers for the current date. You'd like to modify the application such that whenever a date is selected in the Calendar widget, the Data Table refreshes itself by pulling quotes for that date.

The Calendar widget already publishes an event to "/yahoo/calendar/onSelect" topic. All you need to do is modify 'component.js' in Web pages, resources, yahoo, dataTable subtree and listen to that topic. For that, you add the following statement:

jmaki.subscribe("/yahoo/calendar/onSelect", calendarListener);

on line 172 of 'component.js'. The 'calendarListener' function is defined as:

function calendarListener(item) {
    var targetDiv = document.getElementById("newpage");
    targetDiv.innerHTML = item.value;
}

On 'index.jsp', where both the widgets live together, a new <div> is added:

<div id="newpage"></div>

Now any date selected in the calendar is printed on the page. The 'calendarListener' function can be easily modified such that the dataTable is refreshed after processing the date.

We created a simple, yet powerful example, demonstrating jMaki publish/subscribe mechanism.

The mechanism is simple so it should just work even if there are custom widgets and they publish events to their own topic. But this is software so in all likelihood don't be surprised if it does not :) But jMaki at least provide a way to debug that situation. Open 'Web pages', 'resources', 'jmaki.js'. Search for 'this.debugGlue=false;this.debug=false;' in this file. Change the 'false' to 'true' and save the file. After you refresh your application in the browser window, the bottom-right portion of your browser window shows all the topics and messages published on it as shown below:

Happy debugging!

All jMaki Web applications can be deployed on GlassFish or Rails applications can be WARed and then deployed on GlassFish.

Technorati: jmaki glassfish rails rubyonrails

del.icio.us | furl | simpy | slashdot | technorati | digg |
|

Gmail equivalence

a.r.u.n.g.u.p.t.a-AT-gmail-DOT-com is the same as arungupta-AT-gmail-DOT-com or a.rungup.ta-AT-gmail-DOT-com.

Read for more details. New learning every day :)

Technorati: gmail

del.icio.us | furl | simpy | slashdot | technorati | digg |
|
« Previous day (May 20, 2007) | Main | Next day (May 22, 2007) »

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.