V1147
(V S)
1
Hello Goran,
I ran into a problem when trying to save the values of the combobox to the object. I bound the combobox to a HashSet attribute of a class.
If I have at least one item selected, it works as expected.
However, if I have no item selected and I try to save the object I get an error in the following line:
binder.writeBeanIfValid(currentObject))
Error message:
java.lang.RuntimeException: java.lang.ClassCastException: Cannot cast java.util.Collections$EmptySet to java.util.HashSet
Goran32
(Goran Atanasovski)
2
Hi,
Thanks for raising this issue. I think it might be related to how the component is initialized internally (will have to further look into it).
As a way to work around this, one way to control the value that gets written to the bean is to use a converter as described here: https://vaadin.com/docs/v14/flow/binding-data/tutorial-flow-components-binder-validation.html#converting-user-input
Hope this helps,
Goran
V1147
(V S)
3
What solved it for me was that I set the type of my object-attribute (previously HashSet) to Collection (two abstraction levels higher).
Afterwards it could also handle Collection$EmptySet and all was fine :) No need for the converter.
Thanks for the quick reply anyway!