Creating new objects inside a CompositeEditor causing failure in checkStreamsNotCrossed

140 views
Skip to first unread message

Eric Andresen

unread,
May 10, 2011, 10:13:47 AM5/10/11
to google-we...@googlegroups.com
Can anyone take a look at this and let me know if this flow seems sane?  I'm seeing an error:

Caused by: java.lang.AssertionError: Unfrozen bean with null RequestContext
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkStreamsNotCrossed(AbstractRequestContext.java:841)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:425)

doing this.

I have a CompositeEditor that needs to be able to make a server call to get a "template" object that it then spawns a new editor for.  
I have an outer object OuterObject that contains a collection of InnerObject.  

1.  Instantiate OuterObjectEditor with a RequestFactoryEditorDriver and a context.
This calls the setValue and populates the InnerObjectCompositeEditor with the current values, which are displayed in a table.
2.  User clicks a button to add a new InnerObject, which creates a new context, makes a server call to create the new object, and calls back with the new InnerObject.
3.  Instantiate a new RequestFactoryEditorDriver and InnerObjectEditor for the InnerObject, call driver.edit(OuterObjectEditor's context, innerObject) and attach the editor to the chain.
4.  The user edits the new object and clicks save.
5.   Flush the InnerObjectEditor using the inner driver , and call chain.getValue() to read the new object's values and display it in the table.
6.  The user clicks save and everything saves properly.
7.  As a result of the save, the saved OuterObject (with inner objects) is reloaded and passed back in to the outerObjectEditActivity.  
8.  The activity creates a new context, and calls driver.edit(returned OuterObject, new context) 
  This last step throws an exception :


Caused by: java.lang.AssertionError: Unfrozen bean with null RequestContext
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.checkStreamsNotCrossed(AbstractRequestContext.java:841)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:425)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext$3.visitCollectionProperty(AbstractRequestContext.java:896)
    at com.mypackage....OuterObjectProxyAutoBean_com_google_web_bindery_requestfactory_shared_impl_EntityProxyCategory_com_google_web_bindery_requestfactory_shared_impl_ValueProxyCategory_com_google_web_bindery_requestfactory_shared_impl_BaseProxyCategory.traverseProperties(OuterObjectProxyAutoBean_com_google_web_bindery_requestfactory_shared_impl_EntityProxyCategory_com_google_web_bindery_requestfactory_shared_impl_ValueProxyCategory_com_google_web_bindery_requestfactory_shared_impl_BaseProxyCategory.java:268)
    at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.traverse(AbstractAutoBean.java:166)
    at com.google.web.bindery.autobean.shared.impl.AbstractAutoBean.accept(AbstractAutoBean.java:101)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.cloneBeanAndCollections(AbstractRequestContext.java:866)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.editProxy(AbstractRequestContext.java:441)
    at com.google.web.bindery.requestfactory.shared.impl.AbstractRequestContext.edit(AbstractRequestContext.java:418)
    at com.google.web.bindery.requestfactory.gwt.client.impl.RequestFactoryEditorDelegate.ensureMutable(RequestFactoryEditorDelegate.java:137)
    at com.google.gwt.editor.client.impl.BaseEditorDriver.doEdit(BaseEditorDriver.java:89)
    at com.google.web.bindery.requestfactory.gwt.client.impl.AbstractRequestFactoryEditorDriver.edit(AbstractRequestFactoryEditorDriver.java:177)
    at com.mypackage....OuterObjectEditActivity.edit(OuterObjectEditActivity.java:196)
...


My best guess is that there is something stale hanging around in the editor, since my setValue call on my innerObjectCompositeEditor has not yet been called.  When I look at the collection in the cloneBeanAndCollections method in the stack trace in a debugger, it only has the old items, not the newly created item.  Is there some way to tell the driver to discard anything it has in the editor, and start over with the new object?

Thanks,
Eric

Brandon Donnelson

unread,
Feb 7, 2012, 10:25:25 AM2/7/12
to google-we...@googlegroups.com
Did you ever find out why this was happening?

I have the same thing happening when I try to edit the object that is passed back fron the persisted instance.

Brandon Donnelson

unread,
Feb 7, 2012, 10:46:17 AM2/7/12
to google-we...@googlegroups.com
Since I switched to JPA the children (in my case todos) are nto being sent back on the persist. getPaths() shows todos, but why is JPA not getting my children of the owned collection?

Eric Andresen

unread,
Feb 7, 2012, 11:13:55 AM2/7/12
to google-we...@googlegroups.com
Brandon, 

  I traced my problem down to I was trying to do some of the plumbing that the Editor framework does for me by myself.  In particular, my step #3 above was wrong, I shouldn't have been creating a new driver for the sub-editor;  Instead I just had to attach the sub-editor to the list editor's chain.

I did have to do one hack to make everything flush out properly:

After adding the new object and editor to the chain, i had to fix the request context for the sub-editor in order to see its changes at flush time:

    RequestFactoryEditorDriver<?, ?> driver = getDriver();
    if (driver != null)
    {
        ((BaseEditorDriver<?, ?>) driver).accept(new EditorVisitor()
        {
            @SuppressWarnings("hiding")
            @Override
            public <T> void endVisit (EditorContext<T> ctx)
            {
                RequestFactoryEditorDelegate<?, ?> delegate = (RequestFactoryEditorDelegate<?, ?>) ctx
                        .getEditorDelegate();
                if (delegate != null)
                {
                    delegate.setRequestContext(context);
                }
                Editor<T> editor = ctx.getEditor();
                if (editor instanceof HasRequestContext)
                {
                    ((HasRequestContext<T>) editor).setRequestContext(context);
                }
            }
        });
    }


---------------------------------------------------
Eric Andresen


On Tue, Feb 7, 2012 at 9:46 AM, Brandon Donnelson <branfl...@gmail.com> wrote:
Since I switched to JPA the children (in my case todos) are nto being sent back on the persist. getPaths() shows todos, but why is JPA not getting my children of the owned collection?

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/zjqPv2ZvNywJ.

To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

Brandon Donnelson

unread,
Feb 7, 2012, 11:50:53 AM2/7/12
to google-we...@googlegroups.com
Thanks for the info. 

Reply all
Reply to author
Forward
0 new messages