Hi all,
I uses Vaadin 14 and I have problem with correct refreshing items in dependent ComboBox’es. I have one main ComboBox (comboProfile) and 2(comboEnvironment and comboScenario) which have pool of items dependent from selected value in first boxes.
comboProfile.addValueChangeListener((HasValue.ValueChangeEvent<String> event) -> {
String value = event.getValue();
switch (value) {
case "1":
comboEnviroment.setItems("11", "12");
break;
case "2":
comboEnviroment.setItems("21");
break;
case "3":
comboEnviroment.setItems("31", "32", "33");
break;
case "4":
comboEnviroment.setItems("34");
break;
}
comboScenario.setItems(scenarioList.stream().filter(c -> c.getProfile().equals(value)).map(Scenario::getName));
});
Items are always correct refresh in combobox,where operation in done first (in this case comboEnvirnment), but for combobox where it is done next these items have been never refreshed ( in this case comboscenario). Only when I try to set them for the first time everything is correct. When I try to modificade them again by change value for main ComboBox( when all comboboxes has some values). I have error like that for last ComboBoxes(comboScenario)
2021-02-23 16:15:24.567 ERROR 5272 --- [nio-8080-exec-6]
c.v.flow.server.DefaultErrorHandler :
java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135) ~[na:1.8.0_201]
at com.comarch.telco.t3arts.datagenerator.VaadinGUI.onScenarioCombobox(VaadinGUI.java:184) ~[classes/:na]
at com.comarch.telco.t3arts.datagenerator.VaadinGUI.lambda$addValuesChangesListeners$3fab9f70$3(VaadinGUI.java:129) ~[classes/:na]
at com.vaadin.flow.component.internal.AbstractFieldSupport.lambda$addValueChangeListener$828eca10$1(AbstractFieldSupport.java:96) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:205) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.ComponentEventBus.fireEvent(ComponentEventBus.java:194) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.Component.fireEvent(Component.java:359) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.ComponentUtil.fireEvent(ComponentUtil.java:386) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.internal.AbstractFieldSupport.setValue(AbstractFieldSupport.java:207) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.internal.AbstractFieldSupport.setValue(AbstractFieldSupport.java:133) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.AbstractField.setValue(AbstractField.java:181) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.combobox.ComboBox.setValue(ComboBox.java:345) ~[vaadin-combo-box-flow-3.2.2.jar:na]
at com.vaadin.flow.component.HasValue.clear(HasValue.java:179) ~[flow-server-2.4.0.jar:2.4.0]
at com.comarch.telco.t3arts.datagenerator.VaadinGUI.onRandomizeButtonAction(VaadinGUI.java:354) ~[classes/:na]
at com.comarch.telco.t3arts.datagenerator.VaadinGUI.lambda$addValuesChangesListeners$9b1b5227$2(VaadinGUI.java:142) ~[classes/:na]
at com.vaadin.flow.component.ComponentEventBus.fireEventForListener(ComponentEventBus.java:205) ~[flow-server-2.4.0.jar:2.4.0]
at com.vaadin.flow.component.ComponentEventBus.handleDomEvent(ComponentEventBus.java:373) ~[flow-server-2.4.0.jar:2.4.0]
.
.
I just tried to clear this combobox and set its value to null before setting new items but always this is the same effects and items which was set once can’t be refresh.
I’m new with this framework and will be grateful for help because don’t have idea where I made mistake