Hi there,
I have a problem when resetting the value of a RadioButtonGroup if this component is reused (e.g. in a Dialog). The last value is still selected in the frontent even if I reset the value to empty in the backend before.
Here is a sample code:
enum TestEnum {
A,
B,
C
}
public MainView() {
CheckboxGroup<TestEnum> checkboxGroup = new CheckboxGroup<>();
checkboxGroup.setDataProvider(new ListDataProvider<TestEnum>(Arrays.asList(TestEnum.values())));
checkboxGroup.setValue(checkboxGroup.getEmptyValue());
Dialog dialog = new Dialog();
dialog.add(checkboxGroup);
Button button = new Button("Click me",
event -> {
Notification.show("Length of valueset before reset:" + checkboxGroup.getValue().size()
+ " Selected:" + checkboxGroup.getValue());
checkboxGroup.setValue(checkboxGroup.getEmptyValue());
checkboxGroup.deselectAll();
Notification.show("Length of valueset after reset:" + checkboxGroup.getValue().size() + " Selected:"
+ checkboxGroup.getValue());
dialog.open();
});
add(button);
}
Scenario:
- Click the button
- Select something
- close the dialog by clicking outside of it
- Click the button again…
- You will see that the Item is still selected even though the RadioButtonGroup is set to emptyValue before, I also tried deselectAll().
What am I doing wrong here?