简体   繁体   中英

GWT List Objects

We are currently developing a GWT-App and we need a chooser for People. Problem is that we can't use the names of the people as List items alone, because we have some (unfortunately intended) duplicates in our database. So we need some kind of drop-down list, which allows us to have some kind of ID attached to it. Right now we are using GTW bootstrap3's select, which isn't working out for us because we can only get the String of the selected item back. Any help is appreciated!

EDIT: The best solution for us would be to be able to save objects into the lists and display them via some toString() method or something like that.

A standard GWT ListBox allows you to associate a value with each item displayed in the list. You just need to add CSS styles to make it look like the rest of your UI.

You can have an ID and Text in Bootstrap Select. When adding an item to the Select do:

Option option = new Option();
option.setValue(ID);
option.setText(TEXT);

select.add(option);

When you call select.getValue() you will get an ID.

Option is org.gwtbootstrap3.extras.select.client.ui.Option and both value and text is of type String .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM