1 Reply Latest reply on Feb 13, 2019 4:33 AM by totoleheros1234

    Errai : Generic DataBinding for enums




      I give a try to errai. For now, I am interested only in client side (UI/DataBinding/Navigation).


      I had a generic component using Editor for enums rendering in radio button done with gwtbootstap3. I would like to adapt it in order to use it in the Errai DataBinding

      I started with a simplify example with a particular enum : "UnansweredYesNoUnknown"

      So I created a component based on ButtonGroup (gwtbootstrap3) implementing TakesValue<UnansweredYesNoUnknown>

      I added the corresponding @DataField in my page :

      @Inject @DataField @Bound public UnansweredYesNoUnknownEditor isNiceGuy;


      Almost everything goes right (the radiobutton group is rendered, the data is set correctly from the data bean, the model is updated in the UnansweredYesNoUnknownEditor).

      The only problem is that changes in GUI not come back to the bean when calling binder.getModel(), the method getValue() is not excuted.


      Did I miss something ?


      Thanks in avance for any help



      The UnansweredYesNoUnknownEditor code :

      public class UnansweredYesNoUnknownEditor extends ButtonGroup implements ClickHandler,TakesValue<UnansweredYesNoUnknown>{


          private Map<RadioButton, UnansweredYesNoUnknown> map;



          private UnansweredYesNoUnknown model;



      // add RadioButton in ButtonGroup

      //  add click handler on each RadioButton in order to change the model

      public UnansweredYesNoUnknownEditor() {

          String name = "rb";

              map = new HashMap<RadioButton, UnansweredYesNoUnknown>();

              for (UnansweredYesNoUnknown e: UnansweredYesNoUnknown.values()){

                  RadioButton rb = new RadioButton(name.replaceAll(" ", "_"), e.getDisplayValue());



                  map.put(rb, e);








          public void setValue(UnansweredYesNoUnknown value) {

              if (value==null)


              RadioButton rb = (RadioButton) super.getWidget(value.ordinal());


              model = value;






          public UnansweredYesNoUnknown getValue() {

                return model;




      // on click


      public void onClick(ClickEvent event) {

      for (Entry<RadioButton, UnansweredYesNoUnknown> e: map.entrySet())


           if (e.getKey().getValue())


           model = e.getValue();