PDA

View Full Version : HttpProxy will not work when specifing api params, it says it requires url param



tl4764
3 Apr 2011, 12:42 PM
Sencha Touch version 1.1.0
Testing/debugging via latest version of Chrome

The code snippet:
var proxy = new Ext.data.HttpProxy({
//url: 'Service2/GetAll',
api: {
load: { url: 'Service2/GetAll' },
destroy: { url: 'Service2/Delete' },
save: { url: 'Service2/Update' },
create: { url: 'Service2/New' }
}
});
var store = new Ext.data.JsonStore({
autoDestroy: true,
proxy: proxy,
id: 'store',
autoSave: true,
restful: true,
paramNames: { format: 'json' },
fields: [fld1, 'fld2', 'fld3']
});

var list = new Ext.List({
fullscreen: true,
title: 'tstList',
cls: 'list',
scroll: 'vertical',
store: store,
itemTpl: '<div class=ListFirstLine><span class=fld1>{fld1}</span><span class=fld2>{fld2}</span></div><div class="fld2">{fld2}</div>',
listeners: {
//rowNum is zero based.
itemtap: function (dv, rowNum, el, e) {
curRecord = dv.getRecord(el);
panelMain.setActiveItem(1);
panelDetail.update(curRecord.data);
}
}
});

The Problem:
When the url param is specified (in the HttpProxy class) everything works as expected. It gets the data and updates the list. When a specific item in the list is selected it goes to a detailed view of that item, where a delete button is also on the screen. When the Delete button is pushed it issues a POST back to the URL. However, I need to specify the Urls for each specific CRUD action. When the Url param is present it ignores the api params. When I delete the url param; I hit the code below, which gives an errror:

(lines 8626-8638 in sencha-touch-debug.js)
buildUrl: function(request) {
var url = request.url || this.url;

if (!url) {
throw new Error("You are using a ServerProxy but have not supplied it with a url.");
}

if (this.noCache) {
url = Ext.urlAppend(url, Ext.util.Format.format("{0}={1}", this.cacheString, (new Date().getTime())));
}

return url;
},

In the examples I've seen (in extjs, not touch; http://dev.sencha.com/deploy/dev/examples/writer/writer.html) you are not suppose to specify the url param.

Thanks