Friday, July 10, 2020

Re: Problem decoding complex AutoBean

I'm not seeing any issue with that code and sample JSON. Here's a quick entrypoint that I made:

    public void onModuleLoad() {
        IWebchatThemeConfigurationBean bean = deserializeFromJson("{\n" +
                "    \"themeId\": 1,\n" +
                "    \"name\": \"rpc\",\n" +
                "    \"enabled\": true,\n" +
                "    \"propertiesList\": [\n" +
                "        {\n" +
                "            \"id\": 1,\n" +
                "            \"themeConfigurationId\": 1,\n" +
                "            \"chatScreen\": \"chatScreen\",\n" +
                "            \"component\": \"header\",\n" +
                "            \"property\": \"text\",\n" +
                "            \"value\": \"HELLO\"\n" +
                "        },\n" +
                "        {\n" +
                "            \"id\": 3,\n" +
                "            \"themeConfigurationId\": 1,\n" +
                "            \"chatScreen\": \"chatScreen\",\n" +
                "            \"component\": \"background\",\n" +
                "            \"property\": \"color\",\n" +
                "            \"value\": \"rgba(0,191,255,0.5)\"\n" +
                "        }\n" +
                "    ]\n" +
        DomGlobal.console.log(bean.getThemeId() + "");
        DomGlobal.console.log(bean.getPropertiesList().size() + "");
        DomGlobal.console.log(bean.getPropertiesList().stream().map(IWebchatThemeConfigurationPropertyBean::getValue).collect(Collectors.joining(", ")));

Notice that after running your parse method, it dumps the output to the JS console - here is the output:
[com.vertispan.draw.connected.client.FlowChartEntryPoint_IWebchatThemeConfigurationPropertyBeanAutoBean$2@1b, com.vertispan.draw.connected.client.FlowChartEntryPoint_IWebchatThemeConfigurationPropertyBeanAutoBean$2@1c]
HELLO, rgba(0,191,255,0.5)

It seems to be working?

One note: if you do not actually call the properties() method, it is not needed in the factory, since the IWebchatThemeConfigurationPropertyBean type is already reachable from IWebchatThemeConfigurationBean.

Using GWT 2.8.2 for this test.

On Friday, July 10, 2020 at 3:23:35 PM UTC-5, Akshay Kumar wrote:
Can anyone help me?
My json string is - 
"themeId": 1,
"name": "rpc",
"enabled": true,
"propertiesList": [
"id": 1,
"themeConfigurationId": 1,
"chatScreen": "chatScreen",
"component": "header",
"property": "text",
"value": "HELLO"
"id": 3,
"themeConfigurationId": 1,
"chatScreen": "chatScreen",
"component": "background",
"property": "color",
"value": "rgba(0,191,255,0.5)"

Interfaces are -

public interface IWebchatThemeConfigurationBean { public Integer getThemeId(); public String getName(); public Boolean getEnabled(); public List<IWebchatThemeConfigurationPropertyBean> getPropertiesList(); }
public interface IWebchatThemeConfigurationPropertyBean { public Integer getId(); public Integer getThemeConfigurationId(); public String getChatScreen(); public String getComponent(); public String getProperty(); public String getValue(); }

public interface ChatFactory extends AutoBeanFactory {
        AutoBean<IWebchatThemeConfigurationBean> theme();

        AutoBean<IWebchatThemeConfigurationPropertyBean> properties();
    ChatFactory factory;
factory = GWT.create(ChatFactory.class);

IWebchatThemeConfigurationBean deserializeFromJson(String json) { AutoBean<IWebchatThemeConfigurationBean> bean = AutoBeanCodex.decode(factory, IWebchatThemeConfigurationBean.class, json); return; }

in this returned bean I'm getting null propertiesList.
name, enabled, themeId are fine.

On Tuesday, August 20, 2013 at 8:07:30 AM UTC+5:30, Thad Humphries wrote:
I've managed a simple AutoBean with a list. Now I've a more complex one, and I don't understand what's wrong. My get methods are returning null though the debugger shows the object has data.

The JSON looks like this:

      "screenname":"Index Card",
            {"title":"Name",  "name":"odname",   "value":"*TIFF*"},
            {"title":"Date",  "name":"oddate",   "value":""},
            {"title":"Ref #", "name":"odrefnum", "value":""}

I have three interfaces:

public interface Field {
  String getTitle();
  void setTitle(String title);
  String getName();
  void setName(String name);
  String getValue();
  void setValue(String value);

public interface FieldList {
  List<Field> getField();
  void setField(List<Field> field);

public interface MQuery {
  String getScreenname();
  void setScreenname(String screenname);
  FieldList getFields();
  void setFields(FieldList fields);

In my bean factory, I have

public interface BeanFactory extends AutoBeanFactory {
  AutoBean<Field> field();
  AutoBean<FieldList> fields();
  AutoBean<MQuery> mquery();

In my onResponseReceived() method, I call

  AutoBean<MQuery> mqueryBean = 
          MQuery.class, response.getText());
  MQuery mQuery =;
  logger.log(Level.INFO, mQuery.getScreenname());
  screenName = mQuery.getScreenname();
  fieldList = mQuery.getFields().getField();

When I look at the debugger in Chrome, screenname, etc are populated (in mQuery:this$0:data_0 there is mquery with screenename set and 3 field objects in fields). However mQuery.getScreenname() returns null as does mQuery.getFields().

What am I not seeing here? Could the presence of other AutoBean<>s in my factory (beans that work) be messing me up (do I need a separate factory)?

You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

No comments:

Post a Comment