我正在使用 vaadin 应用程序,一个页面有两个组合框 1. Country 2. States
基于我想填充状态的国家下拉值。使用 valuechangeevent 我检索了该国家/地区的所有州我如何加载到州下拉菜单。
请帮助我 :)
我正在使用 vaadin 应用程序,一个页面有两个组合框 1. Country 2. States
基于我想填充状态的国家下拉值。使用 valuechangeevent 我检索了该国家/地区的所有州我如何加载到州下拉菜单。
请帮助我 :)
下面的示例代码可以帮助您实现您想要的
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);
}
});