I want to add a role field (String) like this:<pre spellcheck="false

I want to add a role field (String) like this:

formFactory.setFieldProvider(Person.ROLE_PROPERTYID, new CheckBoxGroupProvider<>("Role", List.of("ROLE_USER", "ROLE_ADMIN"), (ItemLabelGenerator<String>) item -> item));


But get a:

Caused by: java.lang.ClassCastException: Cannot cast java.util.Collections$EmptySet to java.lang.String
	at java.base/java.lang.Class.cast(Class.java:3889) ~[na:na]
at com.vaadin.flow.data.converter.Converter.lambda$from$957be2b0$1(Converter.java:104) ~[flow-data-23.1.2.jar:23.1.2]

at com.vaadin.flow.data.binder.Result.of(Result.java:90) ~[flow-data-23.1.2.jar:23.1.2]

... 134 common frames omitted


I don’t understand why. The code I wrote seems quite valid.

Sorry for the very late reply. I never got a notification about this from the Vaadin Directory. Did you find the solution to the error?