开发者

Vaadin Combo Box

开发者 https://www.devze.com 2023-02-12 04:56 出处:网络
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.

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);
            }
        });
0

精彩评论

暂无评论...
验证码 换一张
取 消