com.google.web.bindery.autobean.shared.impl.AutoBeanCodexImpl

    @Override
    public boolean visitValueProperty(String propertyName, Object value, 
PropertyContext ctx) {
      if (value != null && 
!value.equals(ValueCodex.getUninitializedFieldValue(ctx.getType()))) {
        encodeProperty(propertyName, value, ctx);
      }
      return false;
    }

If I create an AutoBean with set/get for an native number type, say int, 
and set that value to zero then it is not in the result of 
AutoBeanCodex.encode(bean).getPayload()
So if the bean only contains that field and it is set to zero the resulting 
payload is {}

I would think it should be {"myIntValue":0} shouldn't it?

public class AutoBeanPoc implements EntryPoint {

    private PocBeanFactory beanFactory = GWT.create(PocBeanFactory.class);

    interface PocBeanFactory extends AutoBeanFactory {
        AutoBean<PocBean> pocBean();
    }

    interface PocBean {
        void setIntValue(int intValue);
        int getIntValue();
    }

    static class PocJsObject extends JavaScriptObject {
        protected PocJsObject() {  }

        public final native int getIntValue() /*-{
            if(typeof(this.intValue) == "undefined") {
                throw "intValue is undefined"
            }
            return this.intValue;
        }-*/; 
    }

    @Override
    public void onModuleLoad() {
        PocBean bean = beanFactory.pocBean().as();
        bean.setIntValue(0);

        String payload = 
AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(bean)).getPayload();
        PocJsObject jsObj = JsonUtils.safeEval(payload);
        try {
            RootPanel.get().add(new HTML("intValue is " + 
jsObj.getIntValue()));
        }
        catch (JavaScriptException e) {
            RootPanel.get().add(new HTML(e.toString()));
        }
    }
}

I would be interested to hear the communities thoughts before I take the 
plunge and file a report.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to