RequestFactory only send changes

104 views
Skip to first unread message

regis.dev

unread,
Sep 16, 2011, 10:31:35 AM9/16/11
to google-we...@googlegroups.com

I create a form for editing an EntityProxy(campaignProxy) with the Editor + RequestFactory, everything is working/saved in Database (create/edit).

But when i am editing a existing an existing Entity, all the entity is send (i seeing this behaviour in firebug), even i made any changes in my object.

PRE editorDriver.isDirty() = false
POST editorDriver.isDirty() = false

The editor confirm any changes but in my firebug, in the panel network i see

{"F":"****.CampaignRequestFactory","O":[{"T":"aHB9TlK6zvrYcCFpvMxkS6KFH4w=","V":"NTEuMA==","P":{"flights":[{"T":"Y4M0dDfC34axdGshieWi$JsiuEQ=","S":"MjguMA=="},{"T":"Y4M0dDfC34axdGshieWi$JsiuEQ=","S":"MzMuMA=="}]},"S":"MzIuMA==","O":"UPDATE"},{"T":"Y4M0dDfC34axdGshieWi$JsiuEQ=","V":"NDkuMA==","P":{"flightDayparts":[{"T":"m7TMD_VGSQ1a8KEFeD5jh$efaYo=","S":"MjkuMA=="}]},"S":"MjguMA==","O":"UPDATE"},{"T":"m7TMD_VGSQ1a8KEFeD5jh$efaYo=","V":"NDkuMA==","S":"MjkuMA==","O":"UPDATE"},{"T":"Y4M0dDfC34axdGshieWi$JsiuEQ=","V":"NTAuMA==","P":{"flightDayparts":[{"T":"m7TMD_VGSQ1a8KEFeD5jh$efaYo=","S":"MzQuMA=="}]},"S":"MzMuMA==","O":"UPDATE"},{"T":"m7TMD_VGSQ1a8KEFeD5jh$efaYo=","V":"NTAuMA==","S":"MzQuMA==","O":"UPDATE"}],"I":[{"P":[{"T":"aHB9TlK6zvrYcCFpvMxkS6KFH4w=","S":"MzIuMA=="}],"O":"o5CHhcaaGm_AeZ6uNN2pVB0XjYQ="}]}

In the documentation is write

On the client side, RequestFactory keeps track of objects that have been modified and sends only changes to the server, which results in very lightweight network payloads





Here my java code

{{{
public class CampaignPanelImpl extends Composite implements CampaignPanel {

   @Override
    public void loadData(CampaignProxy campaignProxy, RequestContext requestContext) {
        this.campaignProxyEdited = campaignProxy;
       
        //create a requestContext if we are in edit mode
        RequestContext request = requestContext == null ? contextProvider.get() : requestContext;
        editorDriver.initialize(eventBus, requestFactory, listFlightsEditor);
        editorDriver.edit(campaignProxyEdited, request);
       
        listFlightsEditor.setFlightTitles(campaignProxy.getFlights());
    }
   

    @UiHandler("saveContinueButton")
    void save(ClickEvent event) {
        GWT.log("PRE editorDriver.isDirty() = "+editorDriver.isDirty());
        CampaignRequestContext requestContext = (CampaignRequestContext)editorDriver.flush();
        GWT.log("POST editorDriver.isDirty() = "+editorDriver.isDirty());
               
        if (editorDriver.hasErrors()) {
            Window.alert("there is some errors. Cannot save");
            return;
        }   
               
        presenter.save(requestContext,campaignProxyEdited);
    }

}


public class CampaignActivity extends AbstractActivity implements CampaignView.Presenter {
....
    private void edit(String campaingId) {
        contextProvider.get().getCampaignById(new Integer(campaingId)).with("flights", "flights.flightDayparts")
                .fire(new Receiver<CampaignProxy>() {
                    @Override
                    public void onSuccess(CampaignProxy campaignProxy) {
                        editCampaignFlightsView.loadData(campaignProxy, null);
                    }
                });
    }

.....
@Override
    public void save(CampaignRequestContext request, CampaignProxy campaignProxy) {
        request.save(campaignProxy).fire(new Receiver<Void>() {
            @Override
            public void onSuccess(Void response) {
                navigationController.next();
            }

            public void onFailure(ServerFailure error) {
                Window.alert(error.getMessage());
            }

        });
....
    }
}}}


Any Guess, whats wrong. thanks

Thomas Broyer

unread,
Sep 16, 2011, 10:42:56 AM9/16/11
to google-we...@googlegroups.com
RequestContext#isChanged is buggy with collections: http://code.google.com/p/google-web-toolkit/issues/detail?id=5952

regis.dev

unread,
Sep 16, 2011, 12:05:01 PM9/16/11
to google-we...@googlegroups.com
Thanks a lot. I vote for the issue. I will wait for a good workaround or a fix.


Reply all
Reply to author
Forward
0 new messages