Skip to main content

how to get the data

4 replies [Last post]
shengdong
Offline
Joined: 2007-05-22

in the combobox example
[
["Alaska","AK"],
["American Samoa","AS"],
["Arizona","AZ"],
["Arkansas","AR"]]

i get the combobx value 'American' by getValue method
which method i can get the value 'AS' ?

thanks

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
carlavmott
Offline
Joined: 2005-02-10

Here is the code I used to get the value you wanted.

In the JSP page:

value="[
['Item 1','I1'],
['Item 2','I2'],
['Item 4','I4'],
['Item 5','I5'],
['Item 6','I6'],
['Item 7','I7'],
['Item 3','I3']
]" />

In glue.js:

//map topic to combobox
jmaki.addGlueListener("/dojo/combobox", "jmaki.listeners.handleComboBox");

jmaki.listeners.handleComboBox= function(args) {
alert("comboBox value "+ args.value);
}

Looking at the wrapper code I see that the following is used when publishing to the topic:

this.onChange = function(value){
jmaki.publish(topic, {id:wargs.uuid, value: value});
}

dojo.event.connect(this.wrapper, "setSelectedValue", _this, "onChange");

shengdong
Offline
Joined: 2007-05-22

Thank you carlavmott

it can work. And i find another way to do it

in the compnent.js file

add code:
this.getSelectionValue=function(){
return this.wrapper.comboBoxSelectionValue.value;
}

it's also ok.

carlavmott
Offline
Joined: 2005-02-10

Hi Shengdong,

That will work too however we generally tell folks to not change the component.js file only because upgrading to a future release of jMaki may required merging files. If all your code is in the glue.js
file then that is the only file which needs to be "ported". We expect folks to put their code in that file and try not to change it.

Something to think about...

Carla

shengdong
Offline
Joined: 2007-05-22

Thanks Carla .

I will change my code. You are right. Modify the component.js is not a good idea. I lean more...