vaadin - OptionGroup addValueChangeListener CheckBox -


vaadin 7.6.5. trying figure out why value change listener fails in below case? checkbox observing addvaluechangelistener optiongroup.

@theme("vaadindemo") public class vaadindemoui extends ui {      @webservlet(value = "/*", asyncsupported = true)     @vaadinservletconfiguration(productionmode = false, ui = vaadindemoui.class)     public static class servlet extends vaadinservlet {     }      @override     protected void init(vaadinrequest request) {         final verticallayout layout = new verticallayout();         layout.setmargin(true);         setcontent(layout);          optiongroup group = new optiongroup();         group.additem("01");         group.setitemcaption("01", "one");          group.additem("02");         group.setitemcaption("02", "two");          group.additem("03");         group.setitemcaption("03", "three");         group.addvaluechangelistener(new valuechangelistener() {              @override             public void valuechange(valuechangeevent event) {                 system.out.println("group getvalue " + event.getproperty().getvalue());                 system.out.println("group gettype " + event.getproperty().gettype());             }         });         checkbox box = new checkbox();         box.setcaption("check me");         //notify checkbox of value change of radio button          //group.addvaluechangelistener(box); -- // code fails          //box.addvaluechangelistener(group); // selected radio button removed             textfield field = new textfield();         field.addvaluechangelistener(new valuechangelistener() {              @override             public void valuechange(valuechangeevent event) {                 system.out.println("field getvalue " + event.getproperty().getvalue());                 system.out.println("field gettype " + event.getproperty().gettype());                  system.out.println("field gettype " + field.getvalue());             }         });           group.addvaluechangelistener(field);// value reflected. how event without on writing value          //group.addvaluechangelistener(box);          layout.addcomponent(group);         layout.addcomponent(box);         layout.addcomponent(field);          button button = new button("click me");         button.addclicklistener(new button.clicklistener() {             public void buttonclick(clickevent event) {                 layout.addcomponent(new label("thank clicking"));             }         });         layout.addcomponent(button);     }  } 

it logs:

 com.vaadin.data.util.converter.converter$conversionexception: unable convert value of type java.lang.string presentation type class java.lang.boolean. no converter set , types not compatible.     @ com.vaadin.data.util.converter.converterutil.convertfrommodel(converterutil.java:116)     @ com.vaadin.ui.abstractfield.convertfrommodel(abstractfield.java:736)     @ com.vaadin.ui.abstractfield.convertfrommodel(abstractfield.java:721)     @ ... 

i think want like...

    group.addvaluechangelistener(new valuechangelistener() {              @override             public void valuechange(valuechangeevent event) {                  //do box here? e.g...                 box.setvalue(!box.getvalue());              }         }); 

rather than...

group.addvaluechangelistener(box); 

Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -