Vaadin Combo Box
Am using vaadin application, a page having two combo box 1. Country 2. States
based on country i want to populate states drop down value. Using valuechangeevent i retrieved开发者_JAVA百科 all states for the country how can i load to the states drop down.
Pls help me :)
Below sample code may help you implement what you want
AbstractOrderedLayout outerLayout = new VerticalLayout();
final Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> stateList = new ArrayList<String>();
stateList.add("state1");
stateList.add("state2");
stateList.add("state3");
map.put("USA", stateList);
final ComboBox country = new ComboBox("country",map.keySet());
country.setImmediate(true);
outerLayout.addComponent(country);
country.addListener(new Property.ValueChangeListener() {
@Override
public void valueChange(ValueChangeEvent event) {
ComboBox stateComboBox = new ComboBox("state",map.get(country.getValue().toString()));
outerLayout.addComponent(stateComboBox);
}
});
精彩评论