I've been struggling with the RestDataSource (SmartClient 10 evaluation version of October 13th, 2014).
I've defined a BaseRestDataSource that extends RestDataSource and sets it up for a RubyOnRails server.
Please check the part for the "remove" operationBinding. Two scenarios are given, the first one works, but is not in line with the other operations and it does a POST request with a special data attribute that Rails understands and causes it to execute the deletion. The second line is what I would like to have, but it generates the wrong URL (in my opinion).
I've had the dataProtocol attribute set as well on the operation bindings ("getParams" for fetch, "postParams" for the others), but this didn't make a difference so I removed it.
Am I doing something wrong? Or is it a bug?
I've defined a BaseRestDataSource that extends RestDataSource and sets it up for a RubyOnRails server.
Code:
(function (isc, METADATA) { 'use strict'; isc.defineClass('BaseRestDataSource', isc.RestDataSource).addProperties({ dataFormat: 'json', operationBindings: [ { operationType: 'fetch' }, { operationType: 'add' }, { operationType: 'update', requestProperties: { httpMethod: 'PUT' } }, // CORRECT BEHAVIOR // this line generates the correct url (http://url) and sends the data via the post data { operationType: 'remove', requestProperties: { httpMethod: 'POST', params: { '_method': 'DELETE' } } } // INCORRECT BEHAVIOR // this line generates the incorrect url (http://url?id=1&name=something&value=something&authenticity_token=abcdefghiklmnopqrstuvwxz&isc_dataFormat=json) { operationType: 'remove', requestProperties: { httpMethod: 'DELETE' } } ], sendMetaData: false, transformRequest: function (request) { if (request.operationType === 'fetch') { // check if paging is enabled if ((request.startRow !== undefined) && (request.endRow !== undefined)) { request.params = isc.addProperties({}, request.params, { offset: request.startRow, limit: request.endRow - request.startRow }); } } else { request.data = isc.addProperties({}, request.data, { authenticity_token: METADATA.authenticity_token }); } return this.Super('transformRequest', arguments); } }); }(this.isc, this.METADATA));
I've had the dataProtocol attribute set as well on the operation bindings ("getParams" for fetch, "postParams" for the others), but this didn't make a difference so I removed it.
Am I doing something wrong? Or is it a bug?
Comment