Thursday, January 31, 2013

RequestFactory - AutoBean has been frozen - Reloading and editing

I realize this topic has been discussed before but I am having trouble finding a solution to my problem.  Basically I have an editor that needs to edit the same entity in the database multiple times.  I can edit the entity the first time but subsequent edits create the "AutoBean has been frozen" exception.  The whole idea of this code it to load an entity, save the entity, reload the entity, save the entity.... On the server I am just looking up the entity from the database and returning the result.

Here is the relevant code:

....
        editor.addSaveHandler(new SaveHandler() {
            @Override
            public void onSave(final SaveEvent event) {
                save();
            }
        });
        edit();
    ....

    public void edit() {
        driver = GWT.create(Driver.class);
        driver.initialize(factory, editor);
        context = factory.context();
        context.getRegisteredCompany().with(driver.getPaths())
            .fire(new RFReceiver<RegisteredCompanyProxy>(eventBus, driver) {
                @Override
                public void onSuccess(final RegisteredCompanyProxy company) {
                    context = factory.context();
                    driver.edit(company, context);
                    context.save(company);
                }
            });
    }

    public void save() {
        RequestContext ctx = driver.flush();
        if (!driver.hasErrors()) {
            ctx.fire(new RFReceiver<Void>(eventBus, driver) {
                @Override
                public void onSuccess(final Void response) {
                    edit();
                }
            });
        }
    }

Is there something that I am doing wrong with this code?

Thanks!
Steve

--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments:

Post a Comment