Skip to main content

Help with subscribe mechanism of yahoo.dataTable

5 replies [Last post]
bakarirum
Offline
Joined: 2005-07-07
Points: 0

I am using a the yahoo.dataTable. here is widget definition:
(please assume correct syntax in widget definition, etc.. I might have lost something while typing up this post)

]]

in my glue.js I have this:
jmaki.subscribe("/table/results/accounts/onSelect", function(args) {
alert(args.widgetId + "\n" + args.type + "\n" + args.targetId);
});

in another js I have this:
function testMethod() {
var displayTableRows = ... // assume correct syntax for row info
jmaki.publish("/table/results/contacts/addRows", { value : displayTableRows} );
}

When I call the "testMethod" the rows are published to the widget. However, my onSelect function (in the glue.js code above) that I want the widget to subscribe to does not work. The debug window states that the onselect event is being published to:

Publish Match::Topic:/yahoo/yahoo/dataTable/onSelect listener:

So the question is. Since I can publish the addRow event to the widget topic of /table/results/accounts, why can't I subscribe an override function to the onSelect event? Why does the even get published to the default topic? What am I missing?

Thank you for your help.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bakarirum
Offline
Joined: 2005-07-07
Points: 0

Below is an entire test JSP. This will show what I am trying to accomplish. Just simply copy it and paste into a web project and test it out. The Add rows button/funciton shows that the publish method to add new rows works. However, when I subscribe a new function to the topic of /table/results/accounts/onSelect it does not work. The onSelect event is still published to the default topic. I don't know what else to provide. I am using jmaki 1.0.1 (which was loaded from the latest NBM found on ajax.dev.java.net in Netbeans).
<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Default Page


Yahoo Data Table Example Page







Subscribe message:



Add rows:



value="{columns : [
{ label : 'Title', id : 'title'},
{ label :'Author', id : 'author'},
{ label : 'ISBN', id : 'isbn'},
{ label : 'Description', id : 'description'}
],
rows : [
{ title : 'Book Title 1', author : 'Author 1', isbn: '4412', description : 'A Some long description'},
{ id : 'bar', title : 'Book Title 2', author : 'Author 2', isbn : '4412', description : 'A Some long description'}
]
}"
publish="/table/results/accounts"
subscribe="/table/results/accounts"
/>



on select info:


]]>

carlavmott
Offline
Joined: 2005-02-10
Points: 0

Thanks for the test code, I see the problem. There is a bug in the wrapper on line 73. Change 'topic' to 'publish' and it will work. So the code should look like:

if (wargs.publish ) {
-> publish = wargs.publish;
}

I did test it and see that it is working. If you could file a bug that would be great. I will update the wrapper so the fix will be there for the next release. I appreciate the work on finding this.

Carla

bakarirum
Offline
Joined: 2005-07-07
Points: 0

Thanks Carla. That seemed to have fixed my problem. I will file a report and reference this thread.

carlavmott
Offline
Joined: 2005-02-10
Points: 0

Hi bakarirum,

You changed the subscribers for the widget but which topic to publish to. It will publish to the default topic unless you tell it otherwise so you need to add publish="/table/results/accounts" to your tag if you want an onSelect event to be published to that topic.

Carla

bakarirum
Offline
Joined: 2005-07-07
Points: 0

Thanks for the response Carla. I added the publish="" tag to the widget and the onSelect event is still being published to "/yahoo/dataTable/onSelect". Here is the new widget definition

value="{columns : [
{ label : 'City, State Zip', id : 'city' , width : '300px'},
{ label : 'Address', id : 'address' , width : '300px'},
{ label : 'Name', id : 'name' , width : '250px'},
{ label : 'Account', id : 'account' , width : '150px'}
], rows : [
{city : 'city',
address : 'address',
name : 'name',
account : 'account',
id : 'id'}
]
}"
subscribe="/table/results/accounts"
publish="/table/results/accounts"
/>