Thank you, Thomas. That worked.
I added the interface
public interface MQueryWrapper {
MQuery getMquery();
}
In BeanFactory, I changed "AutoBean<MQuery> mquery();" for "AutoBean<MQueryWrapper> mquery();"
My onResponseReceived() now looks like
AutoBean<MQueryWrapper> bean =
AutoBeanCodex.decode(clientFactory.getBeanFactory(), MQueryWrapper.class,
response.getText());
MQuery mQuery = bean.as().getMquery();
logger.log(Level.INFO, mQuery.getScreenname());
screenName = mQuery.getScreenname();
fieldList = mQuery.getFields().getField();
view.renderFields(fieldList);
Client-side this beats overlay types because it can handle nested objects (so long as I figure out nesting). I've not tried it server-side yet, but that looks very handy. However it's probably wise at this early stage to come up with better tags than "field" and "fields" for the XML that my JSON originates from. As more structures are added, I may have conflicts. (I wonder if JSON's XML.toJSONObject() does some magic with namespaces...)
On Tuesday, August 20, 2013 5:34:03 AM UTC-4, Thomas Broyer wrote:
You don't seem to have an AutoBean interface with a "MQuery getMquery()" method.The object you're parsing has only a "mquery" property, so if you look at it as if it were an MQuery object, getScreenname and getFields would expectedly be null.
On Tuesday, August 20, 2013 4:37:30 AM UTC+2, 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:{"mquery":{"screenname":"Index Card","fields":{"field":[{"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 havepublic interface BeanFactory extends AutoBeanFactory {...AutoBean<Field> field();AutoBean<FieldList> fields();AutoBean<MQuery> mquery();}In my onResponseReceived() method, I callAutoBean<MQuery> mqueryBean =AutoBeanCodex.decode(clientFactory.getBeanFactory() , MQuery.class, response.getText());MQuery mQuery = mqueryBean.as();logger.log(Level.INFO, mQuery.getScreenname());screenName = mQuery.getScreenname();fieldList = mQuery.getFields().getField();view.renderFields(fieldList);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 "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment