Hi,

I am playing around with the AutoBean framework as a way to create
JSON from my object models and am using the Editor Framework to do
this.

I have the following model

http://yuml.me/diagram/scruffy/class/%5BNewBusinessOrder%5D-%3E%5BPerson%5D,%20%5BNewBusinessOrder%5D-%3E%5BProduct%5D,%20%5BPerson%5D-%3E%5BAddress%5D

and the "editor" form I am working with looks like this.

http://i52.tinypic.com/anoiev.png

When I create an object using the AutoBeanFactory,


    public NewBusinessOrderProxy makeNewBusinessOrder() {
        AutoBean<NewBusinessOrderProxy> bean =
factory.newBusinessOrder();
        return bean.as();
    }

and "edit" and retrieve it with the editor, all I get is null (the
object was not created).

If I instead initialise with an object "deserialised" from JSON, then
I get in the editor (UiBinder Form) the object I created in JSON.

eg:

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

...

nb = m.deserializeFromJson("{ 'person' : { 'firstName' : 'Ramon' ,
'lastName'  : 'Buckland' , 'address' : { 'street' : 'Brown
St' } } }");


 But, for Any sub Autobean (Address, Product), if I don't specify them
in the property, then serialising the object from the editor, I get
null. (for example, the JSON above, does not specify a product. so
when I debug the flushed object from the editor, having added
"Product" information, the product object does not exist.

Below is the edit and submit handler from the UIBinder form.

What am I missing ? How can I create a blank object with the
AutoBeanFactory and populate and retrieve it in the editor ?

Thanks
ramon


    public void edit() {
        NewBusinessOrderProxy nb = m.makeNewBusinessOrder();
         // nb = m.deserializeFromJson("{ 'person' : { 'firstName' :
'Ramon' , 'lastName'  : 'Buckland' , 'address' : { 'street' : 'Brown
St' } } }");
        editorDriver.initialize(newBusinessOrderEditor);
        editorDriver.edit(nb);
    }

    @UiHandler("submitButton")
    void onSaveClick(ClickEvent event) {
        NewBusinessOrderProxy newBusinessOrder = editorDriver.flush();
        if (editorDriver.hasErrors()) {
            debugTextArea.setText("errord");
        } else {
            if (newBusinessOrder.getPerson() != null) {
 
debugTextArea.setText(m.serializeToJson(newBusinessOrder));
            } else {
                debugTextArea.setText("! was null");
            }
        }
    }

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to