PDA

View Full Version : [FIXED][3.1] Restful Store incorrectly overrides proxy configured HTTP method



magnus76
27 Dec 2009, 8:41 AM
Using a JsonStore (restful enabled), for created HttpProxy, the configuration for HTTP method to use (api configuration) is wrongly overriden in Ext.data.store constructor.


if((this.url || this.api) && !this.proxy){
this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
}

if (this.restful === true && this.proxy) {


this.batch = false;
Ext.data.Api.restify(this.proxy); //Sets HTTP method to CRUD defaults
}I am aware a strict CRUD backend should use methods as POST/GET/PUT/DELETE, but the proxy API for HttpProxy indicates this should be possible to modify even for restful, and confusing impl today.

For reference, my implementation:


var giftsStore = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
api: {
create: {
url: '/api/gifts',
method: 'POST'
},
destroy: {
url: '/api/gifts',
method: 'DELETE'
},
read: {
url: '/api/gifts/',
method: 'GET'
},
update: {
url: '/api/gifts',
method: 'POST'
}
}
}),
//data: successJsonData, //test data
restful: true,
autoDestroy: true,
autoLoad: true,
autoSave: true,
//writer
writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: false // write all fields, not just those that changed
}),

//reader configs
root: 'items',
idProperty: 'key',
fields: [
{name: 'reserved', type: 'boolean'},
{name: 'reserved_by_user', type: 'boolean'},
'url',
'title',
],
listeners:
{
exception: function(a, b, c, d, e, f)
{
console.debug('loadexception!')
},
load: function()
{
console.debug('load!')
},
beforeload: function(a, b)
{
}
}


});

As a result, update requests will still use default PUT method.

Running ext 3.1.0, and with current implementation of Ext.data.store, update will always run with PUT method.

hendricd
28 Dec 2009, 7:58 AM
Fixed in SVN.