|
Replies:
4
-
Last Post:
Nov 7, 2007 12:31 PM
by: sloanb
|
|
|
|
|
|
|
Listeners and custom mapped listener methods
Posted:
Nov 6, 2007 3:26 PM
|
|
|
I'm finally beginning to somewhat understand how things are meshed together with jMaki but I still have lots to learn. One thing that is still unclear to me is the user of custom events with widgets and how to setup them up. For example lets say I have a table and I want a custom onSelect listener to be registered with the dojo.table when the user clicks on the table row. To my understanding you should simple put a custom listener in the glue.js and have the widget (dojo.table) subscribe to it. When the widget publishes to this it will call the method and perform that logic. Am I way off base here? I've been working through several of the examples but haven't figured it out completely yet.
In my example glue.js I'm creating the following
jmaki.listeners.dojo.table = { onSelect : function(args) { // Perform logic } }
Am I on the right track? From here what needs to be done?
|
|
|
|
|
|
|
Re: Listeners and custom mapped listener methods
Posted:
Nov 6, 2007 3:36 PM
in response to: sloanb
|
|
|
Each widget has its own pre-defined events. Forexample onSelect event for yahoo data table.
in glue.js :
// map topics for yahoo dataTable selection jmaki.subscribe("/yahoo/dataTable/onSelect", function(args) { jmaki.log("glue.js : onSelect request from: " + args.widgetId);
//implement your method here });
in your jsp: <a:widget id="teamtable" name="yahoo.dataTable" service="page_user_getteamsbasedonfilter.jsp" />
if you like to use custom name for the publish subscribe mechanism, you have to specify the publish in the widget. <a:widget id="teamtable" publish="/anything/whatever" name="yahoo.dataTable" service="page_user_getteamsbasedonfilter.jsp" />
Your glue.js will be:
// map topics for yahoo dataTable selection jmaki.subscribe("/anything/whatever/onSelect", function(args) { jmaki.log("glue.js : onSelect request from: " + args.widgetId);
//implement your method here });
I'm still learning too. So let me know if you find a better way.
|
|
|
|
|
|
|
|
Re: Listeners and custom mapped listener methods
Posted:
Nov 6, 2007 4:35 PM
in response to: a_laksmana
|
|
|
I forgot to mention.
Each component.js may be hardcoded to certain topics. For example yahoo.dataTable.
I found out in
/resources/yahoo/dataTable/component.js
It is being hardcoded: var publish = "/yahoo/dataTable";
To enable using the custom publish topic, just replace the above line with:
var publish; if(undefined==wargs.publish){ publish = "/yahoo/dataTable"; } else{publish = wargs.publish;}
Then you can publish to custom topic like:
<a:widget id="teamtable" publish="/myowntopic/whatever" name="yahoo.dataTable" service="page_user_getteamsbasedonfil
|
|
|
|
|
|
|
|
Re: Listeners and custom mapped listener methods
Posted:
Nov 7, 2007 10:20 AM
in response to: a_laksmana
|
|
|
Hi,
Glad you all are looking at jMaki. I did write a blog recently on just this topic that you might find helpful. It also contains pointers to other articles or blogs which might be useful too. Hope this helps. Feel free to send feedback and let me know how to improve it or what is missing.
http://weblogs.java.net/blog/carlavmott/archive/2007/10/connecting_widg.html
Thanks, Carla
|
|
|
|
|
|
|
|
Re: Listeners and custom mapped listener methods
Posted:
Nov 7, 2007 12:31 PM
in response to: carlavmott
|
|
|
Appreciate the response. Yes my company is battling between Google GWT and jMaki. I've used GWT and it works great but something is compelling me to jMaki and I think it will be a better fit for us. Again appreciate the link. Great product.
|
|
|
|
|