0

我正在使用 vaadin 应用程序,一个页面有两个组合框 1. Country 2. States

基于我想填充状态的国家下拉值。使用 valuechangeevent 我检索了该国家/地区的所有州我如何加载到州下拉菜单。

请帮助我 :)

4

1 回答 1

4

下面的示例代码可以帮助您实现您想要的

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);
            }
        });
于 2011-02-22T13:02:14.120 回答