Announcement

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

    transformResponse() not being called with POST operation of a RestDataSource

    SmartClient Version: v9.1p_2015-03-26/Pro Developmentv

    I am trying to upload a file to a REST API and have a callback execute when the file has been uploaded. Below are the relevant portions of my SmartClient code.

    Code:
    uploadFile: function () {
    
        var fileUploadDS, fileUploadForm;
    
        fileUploadDS = isc.RestDataSource.create({
            dataFormat: "json",
            dataURL: isc.Page.getAppDir() + "rest/uploadFile",
            fields: [
                {name: "file", type: "FileItem"}
            ],
    
            transformResponse: function(dsResponse, dsRequest, data) {
    (1)         var dsResponse_o = this.Super("transformResponse", arguments);
                return dsResponse_o;
            }
        });
    
        fileUploadForm = isc.DynamicForm.create({
            dataSource: fileUploadDS,
            width: 300,
    
            fields: [{
                name: "file",
                type: "FileItem",
                title: "Upload file",
                width: 400,
                canEdit: true,
                required: true,
                multiple: false
            }, {
                title: "Upload",
                type: "button",
                click: function () {
    (2)             this.form.saveData();
                }
            }
            ]
        });
    
        ....
    }
    When I click the Upload button (2), I see my POST being executed and I get a 200 response from the server the response data in the SmartClient format:
    Code:
      {"response":{"data":"Ok","invalidateCache":false,"isDSResponse":true,"affectedRows":0,"status":0}}
    and the file was successfully uploaded to the server. However, my breakpoint at (1) does NOT get triggered.

    What does occur is after a few minutes, my breakpoint at (1) is triggered, but the dsResponse has a status of -100 and the data is "Operation timed out".

    I have used the RestDataSource successfully for GET and DELETE and the callback is always executed at the correct time i.e. when the client receives the response from the server.

    What am I doing wrong?

    #2
    We can't see anything obviously wrong with the (partial) code you've shared. Next step would be to update to the latest patched build (you are missing 6 months of fixes), and, if the problem persists, try creating a test case for it.

    Note that a test case won't need to involve your servlet code for a RestDataSource since all server-declared DataSources (those defined by .ds.xml files) support the RestDataSource protocol via the RestHandler servlet.

    Comment


      #3
      I downloaded the latest build for 9.1 (SmartClient Version: v9.1p_2015-09-09/EVAL Deployment) and the problem still exists.

      Comment


        #4
        OK, next step is as noted previously:

        We can't see anything obviously wrong with the (partial) code you've shared. Next step would be to update to the latest patched build (you are missing 6 months of fixes), and, if the problem persists, try creating a test case for it.

        Comment

        Working...
        X