Combobox Suffers me

In my web application i want to add some features like…

1.Combobox will enabled when i select a pre-targeted value on another multiselect combobox(Combobox will disable first).
2.I have a enum class and set this data in two different combobox.If i select one data then it will no longer available for another combobox.

Any expert here or anyone who can give me some idea?

Hi!

Does something like this work for you:

enum MyEnum {
    FOO, BAR, BAZ
};

public MainView() {
    ComboBox<MyEnum> comboBox1 = new ComboBox<>();
    comboBox1.setItems(MyEnum.values());

    ComboBox<MyEnum> comboBox2 = new ComboBox<>();
    comboBox2.setEnabled(false);

    comboBox1.addValueChangeListener(e -> {
        if (e.getValue() == null) {
            comboBox2.setValue(null);
            comboBox2.setEnabled(false);
        } else {
            comboBox2.setItems(Arrays.stream(MyEnum.values())
                    .filter(value -> value != e.getValue()));
            comboBox2.setEnabled(true);
        }
    });

    add(comboBox1, comboBox2);
}

Pekka Maanpää:
Hi!

Does something like this work for you:

enum MyEnum {
    FOO, BAR, BAZ
};

public MainView() {
    ComboBox<MyEnum> comboBox1 = new ComboBox<>();
    comboBox1.setItems(MyEnum.values());

    ComboBox<MyEnum> comboBox2 = new ComboBox<>();
    comboBox2.setEnabled(false);

    comboBox1.addValueChangeListener(e -> {
        if (e.getValue() == null) {
            comboBox2.setValue(null);
            comboBox2.setEnabled(false);
        } else {
            comboBox2.setItems(Arrays.stream(MyEnum.values())
                    .filter(value -> value != e.getValue()));
            comboBox2.setEnabled(true);
        }
    });

    add(comboBox1, comboBox2);
}

Thanks expert.
Can you tell me how can i do it for List?

Not much difference, just get a Stream out of the list instead of the enum:

comboBox2.setItems(list.stream()
  .filter(value -> value != e.getValue()));

This is happening. can you please help me out?

17600297.png
17600300.png

Disabled components should ignore any updates from the client-side. If everything works fine, you don’t have to worry about those message logs.