Announcement

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

    SmartClient 6.5.1: patch for issue with RestDataSource and dataProtocol 'postMessage'

    In SmartClient release 6.5.1 in some cases a RestDataSource with operationBindings' dataProtocol set to 'postMessage' can cause a JS error when performing operations.
    This patch will avoid this error.

    Code:
    //----------------------------------------------------------------------------
    // Isomorphic SmartClient 6.5.1 patch
    // Purpose: Fix for a case where REST dataSources could experience JS Errors 
    // if dataProtocol was set to 'postMessage' for some operations.
    // 
    // Applies to SmartClient 6.5.1 build only
    //----------------------------------------------------------------------------
    if (window.isc && isc.version.startsWith("6.5.1/") ){
    
        if (isc.RestDataSource) {
    isc.RestDataSource.addProperties({    
    transformRequest:function (_1) {
        var _2 = this.getDataProtocol(_1);
        if (_2 == "postMessage") {
            if (this.dataFormat == "json") {
                this.logWarn("DataSource dataProtocol specified for operation as \"postMessage\". Data will be sent to the server as a serialized xml message even though dataFormat is set to \"json\"");
            }
            var _3 = {dataSource: this.getID(), operationType: _1.operationType, operationID: _1.operationID, startRow: _1.startRow, endRow: _1.endRow, sortBy: _1.sortBy, textMatchStyle: _1.textMatchStyle};
            
            var _4 = isc.DataSource.create({fields: [{name: "data", multiple: true, type: this.getID()}, {name: "oldValues", type: this.getID()}]});
            _3.data = _1.data;
            _3.oldValues = _1.oldValues;
            return _4.xmlSerialize(_3, null, null, "request");
        } else {
            if (_2 != "getParams" && _2 != "postParams") {
                this.logWarn("RestDataSource operation:" + _1.operationID + ", of type " + _1.operationType + " has dataProtocol specified as '" + _2 + "'. Supported protocols are 'postParams', 'getParams' " + "and 'postMessage' only. Defaulting to 'getParams'.");
                _1.dataProtocol = "getParams";
            }
            var _3 = isc.addProperties({}, _1.data, _1.params);
            if (this.sendMetaData) {
                if (!this.parameterNameMap) {
                    var _5 = {};
                    _5[this.metaDataPrefix + "operationType"] = "operationType";
                    _5[this.metaDataPrefix + "operationID"] = "operationID";
                    _5[this.metaDataPrefix + "startRow"] = "startRow";
                    _5[this.metaDataPrefix + "endRow"] = "endRow";
                    _5[this.metaDataPrefix + "sortBy"] = "sortBy";
                    _5[this.metaDataPrefix + "textMatchStyle"] = "textMatchStyle";
                    _5[this.metaDataPrefix + "oldValues"] = "oldValues";
                    this.parameterNameMap = _5;
                }
                for (var _6 in this.parameterNameMap) {
                    var _7 = _1[this.parameterNameMap[_6]];
                    if (_7 != null) {
                        _3[_6] = _7;
                    }
                }
                _3[this.metaDataPrefix + "dataSource"] = this.getID();
            }
            return _3;
        }
    }
    
    });
        }
    
    } else if (window.isc) {
      isc.Log.logWarn("Patch for SmartClient 6.5.1 build included in this application. " +
                "You are currently running SmartClient verion '"+ isc.version + 
                "'. This patch is not compatible with this build and will have no effect. " +
                "It should be removed from your application source.");
    
    }
    
    // End of patch
    // ------------
Working...
X