Arun
Arun

Reputation: 1

Adding a list inside a GWT List Box

I have added an List box and and i have an list of value that needs to be populated in the list box. The only option i could find to add values to the list box is listbox.addItem... where i have to iterate the list of values i have and need to add it one by one. Is there any other way where i can add the entire list in one single call.??

private final List<Operation> numberComparisons = Arrays.asList(Operation.EQUAL, Operation.GREATER_THAN, Operation.GREATER_THAN_OR_EQUAL, Operation.LESS_THAN, Operation.LESS_THAN_OR_EQUAL, Operation.FILLED_IN, Operation.EMPTY);

now i have to add this number comparisons list into

ListBox conditionDropDown = new ListBox();
conditionDropDown.addItem(numberComparisons);

..... how can i do this...???

Upvotes: 0

Views: 1559

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64541

Have a look at the ValueListBox widget; you'll then use a Renderer to "generate" the String representation of your Operation (used to display them to the user in the list).

Upvotes: 1

Samoth
Samoth

Reputation: 460

Maybe try this:

class MyListBox extends ListBox {

    public void addAsList(List<Operation> list) {
        for (Operation operation : Operation.values()) {
            addItem(operation.toString());
    }
}

and finally:

MyListBox conditionDropDown = new MyListBox();
conditionDropDown.addAsList(numberComparisons);

Upvotes: 1

Related Questions