RadioButtonGroup's setValue() Method not Selecting RadioButton in Browser

Hello all,

I have a RadioButtonGroup defined in a custom web component:

<vaadin-radio-group id="x"></vaadin-radio-group>

I’m injecting this component into the companion Java class. There, it is typed with a custom Enum:

@Id("x")
private RadioButtonGroup<CustomEnum> rbg;

I’m trying to use Binder to select the proper RadioButton when a data object is loaded. I can verify that Binder is doing its job via RadioButtonGroup’s getValue() method.

bean.setProperty(CustomEnum.A);
binder.readBean(bean);
rbg.getValue() (returns CustomEnum.A)

However, the corresponding RadioButton is not visually selected in the browser.

Running rbg.setvalue(CustomEnum.A) from the server-side yields the same result. No radio button is selected in the browser.

Am I missing a step, or is this a bug?

Thanks for reading,

Bryan

Hi Bryan,

I don’t know if this is related or not. I reported an issue a while back that caused checkboxes to be reset by the client: https://github.com/vaadin/flow/issues/4304

The bug has been marked as closed, but not sure if it has been released in V10/V11 bundles yet.

Perhaps I should mention that the way I noticed the issue was client related was to add a value change listener. It showed that the checkbox was set twice - first time when set/readBean was invoked and the second time after the component was attached.

Test Test Test

Hmm… Not sure why my initial reply didn’t post.

Thanks for the reply, Martin!

I read your bug ticket, and yes, this appears to be another issue with component injection via @Id annotation.

I verified that RadioButtonGroup works as expected when the component is not injected through the @Id annotation.

I’ll keep an eye out for the bug fix in a future Vaadin release.

Thanks again,

Bryan