Icon Issue in RadioButtonGroup component

Hi, it seems there is a bug to set the icon in the RadioButtonGroup item.
I am using

radioButtons.setItemIconGenerator

which returns a FileResource type, but it cannot get the image properly. It works fine when I use the ThemeResource type.

So I checked the url of the FileResource, it is of which the key is
null
.

I checked other Image component which uses FileResource, the url will be like this of which the key is
source
.

Not sure whether the key matters this issue or not. Here is the piece of the code in RadioButtonGroup that might cause the problem,might need to set the key to
AbstractEmbeddedState.SOURCE_RESOURCE
instead of null.

com.vaadin.ui.RadioButtonGroup.java Line 122 - 128

                Resource icon = getItemIconGenerator().apply(data);
                if (icon != null) {
                    String iconUrl = ResourceReference
                            .create(icon, RadioButtonGroup.this, null).getURL();
                    jsonObject.put(ListingJsonConstants.JSONKEY_ITEM_ICON,
                            iconUrl);
                }

BTW, not sure if anyone can explain a little more about ConnectResource, what it is normally used for and how it works etc :slight_smile:

Hi,
it looks like it’s a known issue and there is a bug ticket created about it
RadioButtonGroup/CheckBoxGroup: setting ClassResource as icon renders a broken link

There was a similar discussion in this thread:
ConnectorResources

Could you try a ThemeResource class instead?

Regards,
Anastasia