Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    invalidateCache always false on client's callback

    Hi,
    I am trying to use an optional flag "invalidateCache" which my my RestDataSource compatible serwer is setting to true in some cases. Unfortunately, for a reason I can't find, client reads this flag as false always. To trace it down I prepared the following example in which the server response for add request is imitated in the add.xml static file.
    I will appreciate if anybody can follow this example and show what I am doing wrong here.
    Thanks,
    MichalG
    SGWT daily from 2011-02-21, Firefox 3.6.9, hosted/debug mode, Gentoo linux
    Code:
    <response>
          <status>STATUS_SUCCESS</status>
          <invalidateCache>true</invalidateCache>
          <data>
          </data>
    </response>
    Code:
    package org.yournamehere.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.smartgwt.client.data.DSCallback;
    import com.smartgwt.client.data.DSRequest;
    import com.smartgwt.client.data.DSResponse;
    import com.smartgwt.client.data.OperationBinding;
    import com.smartgwt.client.data.Record;
    import com.smartgwt.client.data.RestDataSource;
    import com.smartgwt.client.types.DSOperationType;
    import com.smartgwt.client.types.DSProtocol;
    import com.smartgwt.client.util.SC;
    
    public class MainEntryPoint implements EntryPoint {
    
        public MainEntryPoint() {
            SC.showConsole();
        }
    
        public void onModuleLoad() {
    
            RestDataSource ds = new RestDataSource();
            OperationBinding add = new OperationBinding();
            add.setOperationType(DSOperationType.ADD);
            add.setDataProtocol(DSProtocol.POSTMESSAGE);
            ds.setOperationBindings(add);
    
            ds.setAddDataURL("add.xml");
    
            ds.addData(new Record(), new DSCallback() {
    
                public void execute(DSResponse response, Object rawData, DSRequest request) {
                    System.out.println("Why always false here !? "+response.getInvalidateCache());
                }
            });
        }
    }

    #2
    To answer my own question:
    Looks like RestDataSource ignores invalidateCache flag.
    Workaround in the transformResponse():
    Code:
        @Override
        protected void transformResponse(DSResponse response, DSRequest request, Object data) {
            response.setInvalidateCache(Boolean.valueOf(XMLTools.selectString(data, "//invalidateCache")));
            super.transformResponse(response, request, data);
        }
    HTH
    MichalG

    Comment

    Working...
    X