Skip to main content

How to call a method of jmaki component through 'id'

4 replies [Last post]
gomathy
Offline
Joined: 2007-03-12

Created a jmaki component using the following tag in a page1.jsp:

mylib.floatingPane has a method called setContents(value) defined in component.js.

Need to call this method during event handling. i.e.

in the jsp page, I am subscribing to an event "mytopic/searchResults" & handling it in a function called handleSearchResults. Can get the access of the component through "var target = document.getElementById("searchResultArea");". But not knowing how to call the setContents(value) method now for this instance of the component.

Will anybody let me know the way to do it.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hat27533
Offline
Joined: 2006-03-16

Hi, I need to do something similar.

Once you have the handle to the widget, how do you update the value (say for a dojo.combo).

Also, how do you know what version of the jmaki lib (best thing since chockie biscuits) you have ?

dinamlab
Offline
Joined: 2005-09-20

I use this to look for an specific dojoComboBox and it works for me yo can try it

[code]

jmaki.addGlueListener({topic: "/dojo/combobox/asentamientos", action: "call", target: {object: "jmaki.listeners.Asentamientos",functionName:"updateMapHandlerAsentamientos"}});

jmaki.listeners.Asentamientos = {

updateMapHandlerAsentamientos : function(value) {
var keys = jmaki.attributes.keys();
for (var l = 0; l < keys.length; l++) {
if(jmaki.widgets.dojo && jmaki.widgets.dojo.combobox && jmaki.widgets.dojo.combobox.Widget &&
jmaki.attributes.get(keys[l]) instanceof jmaki.widgets.dojo.combobox.Widget){
miComboBox = jmaki.attributes.get(keys[l]);
if("theIdSearched"==miComboBox.uuid){
miwidget = miComboBox.comWid;
jmaki.doAjax({
method:"GET",
url: '../../../faces/codigosBean-ciudadesService.ajax?cmd=setValue&value='+value,
asynchronous: false
});
dojo.io.bind({
url: '../../../faces/codigosBean-asentamientosService.ajax?ciudad='+value,
method: "get",
mimetype: "text/json",
load: function (type, data) {
miwidget.dataProvider.setData(data);
}
});
}
}
}
}
}

[/code]

gomathy
Offline
Joined: 2007-03-12

But the id what I have is - "id" specified in the tag & not the uuid.
Another thing is I will have multiple instance of the mylib.floatingpane. Will need to
call that instance method.

gmurray71
Offline
Joined: 2003-07-31

The id used on the tag is the id used on the widget. You can get an instance of a widget by calling:

(working in jMaki .9.1 or greater)

jmaki.getWidget(id)

or for older versions

jmaki.attributes.get(id)

This will give you the instance you want.