Radio Button group created using Designer doesn't trigger the changeValueEvent

197 views Asked by At

I have added Radio Button group by using Vaadin designer to my view :

  <vaadin-radio-group value="Line" id="vaadinRadioGroup" style="margin-left: var(--lumo-space-s);">
   <vaadin-radio-button name="Line" style="flex-grow: 0; align-self: stretch;" checked>
 Line 
  </vaadin-radio-button>
  <vaadin-radio-button name="Heatmap" checked>
 Heatmap 
  </vaadin-radio-button>
 <vaadin-radio-button name="Both" checked>
 Both 
 </vaadin-radio-button>
 </vaadin-radio-group>

And in my java code :

vaadinRadioGroup.addValueChangeListener(radioButtonEvent -> {
        System.out.println("The event is triggered.......")
    });

The change in the radio button value does not trigger the changeValueEvent. Anything I am missing here??

1

There are 1 answers

0
Anna Koskinen On

A bit closer look revealed the problem: with a radio button group you can't declare the data in the design itself if you want to be able to use it from the Java side as well. You should do that from the Java side using e.g. setItems() or adding a DataProvider. If you do that, the individual radio buttons won't be visible when you look at the design, but they'll be there when you run the application.