How to populate one dropdown based on the selection in another in GWT?

322 Views Asked by At

I want to create 2 drop-downs-one with the cities' names and the other with all the historical monuments in that particular district. It should be such that if i select a city 'A' from the first drop-down, the second drop-down is automatically populated with the options of all the monuments in that city.

But I can't find an answer for doing the same in GWT uibinder.

Please help! Thank You!!

1

There are 1 best solutions below

1
Robert Newton On

You use 2 ListBox widgets. Refer to the documentation for that widget about how to use ListBox with uibinder.

In the java code, add a ChangeHandler to the first widget, ListBox.addChangeHandler(), and have the handler call ListBox.getSelectedValue() to get the selected value when it changes. Then populate the 2nd widget based on it using the ListBox.clear() and .add() methods.