views:

29

answers:

1

i want to put items in GWT combobox using database. please provide me any suggestion to get the item of GWT-combobox using database.

A: 

Well, your question doesn't have much detail, so it's hard to know what information you're seeking.

That said, you're probably going to want to create a GWT service with a method like getComboBoxData(). (Alternatively, if you already have a GWT service, you can add a new method to it.) In the implementation of that method (that is, on the server side) you will query the database for the information you want to put in the combo box. This information should them be returned by the getComboBoxData() method. Then, in the onSuccess() method of the callback you used when calling getComboBoxData(), take the data out of onSuccess() method parameter, which will contain the data you returned in getComboBoxData(), and add it to the comboBox with the addItem() method. Btw, the GWT class you want to use for a combo box is ListBox.

I highly recommend you read the documentation that GWT provides, which you can find here. Good luck.

Tony
Hi Tony, First of all thanks a lot for your suggestion. I got it as u say i have created getComboBoxData() in GWT service but the problem is in which datatype,this method will return result means method will return string array, string or any thing else? how to add this result to combobox? if you have any small application for it please provide me, this is very benificial for me.Thanks one again, waiting for your reply Thanks, Arun
Arun
You can return String or any of the other primitive wrapper objects (e.g., Double, Integer, Long, etc.), as well as arrays of those objects, without any problem. If you have a complex object, it needs to implement the IsSerializable interface. The easiest thing to do is probably return a String[] and then on the client side, use a for loop to add each one with addItem().
Tony