繁体   English   中英

Vaadin组合框

[英]Vaadin Combo Box

我正在使用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);
            }
        });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM