Hello everybody!

Just a quick question about the best way to perform something.

I have an extended Listbox that I am populating from a
java.util.List.  My Listbox takes 2 List parameters, the complete list
and the list of selections <same generic type>.

I am looping through my lists one inside the other and telling the
listbox to setSelectedIndex(i) but the problem is that it will not
allow me to select multiple ones programmatically.  At the end of the
loop, only the last item is selected.

As of GWT 1.6 it seems they removed a method to allow multi-selections
to occur for some reason.

Excerpt from javadoc:
[quote]
void com.google.gwt.user.client.ui.ListBox.setSelectedIndex(int index)
Sets the currently selected index. After calling this method, only the
specified item in the list will remain selected. For a ListBox with
multiple selection enabled, see setItemSelected(int, boolean) to
select multiple items at a time.
[/quote]

That mentioned method does not exist anymore.  Now for the listbox to
be a mulit-select you must use the constructor.

[code]
private void prefillSelections() {
                for (int i = 0; i < this.getItemCount(); i++) { // Loop - 
Listbox
items
                        for (int j = 0; j < this.selectedContents.size(); j++) 
{ // Loop-
                                                                                
                                                                // Selections
                                if 
(this.listContents.get(i).getListBoxEntryName().contains(
                                                
this.selectedContents.get(j).getListBoxEntryName())) {
                                        // check on entry name from Data_BaseObj
                                        this.setSelectedIndex(i);
                                }
                        }
                }
        }
[/code]

Any help for best practices or a suggestion?

Thanks for reading and help!
Rob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to