Drop down menu 瓦丁组合盒

Drop down menu 瓦丁组合盒,drop-down-menu,vaadin,Drop Down Menu,Vaadin,我使用的是vaadin应用程序,一个有两个组合框的页面 1.国家 2.州 基于我要填充的国家下拉值。 使用valuechangeevent,我检索了国家/地区的所有州如何加载到“州”下拉列表 请帮助我:)下面的示例代码可以帮助您实现您想要的 AbstractOrderedLayout outerLayout = new VerticalLayout(); final Map<String, List<String>> map = new HashMap<String

我使用的是vaadin应用程序,一个有两个组合框的页面 1.国家 2.州

基于我要填充的国家下拉值。 使用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);
            }
        });
AbstractOrderedLayout outerLayout=新建垂直布局();
final Map=new HashMap();
List stateList=新建ArrayList();
州列表。添加(“州1”);
州列表。添加(“州2”);
州列表。添加(“州3”);
地图放置(“美国”,州列表);
最终组合框国家=新组合框(“国家”,map.keySet());
country.setImmediate(true);
外部布局。添加组件(国家/地区);
country.addListener(新属性.ValueChangeListener(){
@凌驾
public void valueChange(valuechangevent事件){
ComboBox stateComboBox=新的组合框(“state”,map.get(country.getValue().toString());
addComponent(stateComboBox);
}
});

下面的示例代码可以帮助您实现所需的功能

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);
            }
        });
AbstractOrderedLayout outerLayout=新建垂直布局();
final Map=new HashMap();
List stateList=新建ArrayList();
州列表。添加(“州1”);
州列表。添加(“州2”);
州列表。添加(“州3”);
地图放置(“美国”,州列表);
最终组合框国家=新组合框(“国家”,map.keySet());
country.setImmediate(true);
外部布局。添加组件(国家/地区);
country.addListener(新属性.ValueChangeListener(){
@凌驾
public void valueChange(valuechangevent事件){
ComboBox stateComboBox=新的组合框(“state”,map.get(country.getValue().toString());
addComponent(stateComboBox);
}
});