PDA

View Full Version : [FIXED] AjaxProxy with paramsAsJson



bob4ever
15 Apr 2014, 10:49 PM
I think the "paramsAsJson"-property doesnt work correctly in combination with an json writer and extraParams. The extraParams overwrite the jsonData of the writer:

https://fiddle.sencha.com/#fiddle/54m

The request has only the windowId as jsonParam.

Update:
The following overwrite seems to work:


Ext.override(Ext.data.proxy.Ajax, {
doRequest: function(operation) {
var me = this,
writer = me.getWriter(),
request = me.buildRequest(operation),
method = me.getMethod(request);

if (writer && operation.allowWrite()) {
request = writer.write(request);
}

request.setConfig({
binary: me.getBinary(),
headers: me.getHeaders(),
timeout: me.getTimeout(),
scope: me,
callback: me.createRequestCallback(request, operation),
method: method,
useDefaultXhrHeader: me.getUseDefaultXhrHeader(),
disableCaching: false // explicitly set it to false, ServerProxy handles caching
});

if (method.toUpperCase() !== 'GET' && me.getParamsAsJson()) {
// We need to copy the request here, because the params object is attached to
// the request and may be accessed by other callers, since it doesn't really care how the
// information is encoded, so we can't mutate it here.
request.setJsonData(Ext.Object.merge({}, request.getJsonData(), request.getParams()));
request.setParams(undefined);
}

if (me.getWithCredentials()) {
request.setWithCredentials(true);
request.setUsername(me.getUsername());
request.setPassword(me.getPassword());
}
return me.sendRequest(request);
}
});

evant
15 Apr 2014, 11:47 PM
Agreed. It needs to be a bit smarter and not just overwrite it.