Friday, August 8, 2008

Tibco PageBus

Tibco pagebus is an effective tool to pass messages between various widgets and page snippets.
Sometimes you need to look at the full list of subscriptions (especially for debugging) and pagebus is not much help.

The Javascript below will display all the subscriptions by traversing the tree data structure that pagebus keeps.

put this in your javascript in your code somewhere,

testExist(window["OpenAjax"].hub._subscriptions,"com.bigcompany.onClick",0)


window["OpenAjax"].hub._subscriptions is the PageBus object that holds a tree of the PageBus subscriptions.
(Note the period "." separators are also tree nodes.)



The following is the function that actually searches the tree.

function testExist(objectTree, path, i) {
//8 is some arbitrary limit to keep the recursion under control
if(!objectTree || !path || i>8) {
return false;
}
var myPath = path.split(".");

if(myPath.length<=i) {
return true;
}
var newTree=objectTree[myPath[i]];

if(newTree) {
return testExist(newTree, path, i+1);
} else {
//if false, check for "." separator--don't increment i
return testExist(objectTree["."], path, i);
}
}

No comments: