View Full Version : how to create a CRUD ScriptTagProxy

20 Jul 2011, 2:46 AM
hi there!

I thought it would be easy to create a ScriptTagProxy for CRUD-actions - but it isn't...

My code is like:

app.stores.mystore = new Ext.data.Store({

model: 'app.models.User',
proxy: 'userstorage'

Ext.extend(Ext.data.ScriptTagProxy, {
type: 'scripttag',
url : 'http://www.path.to/controller_response.php',
extraParams: {uid: app.theUID},
callbackParam: 'callback',

actionMethods: {
create: 'CREATE',
read: 'READ',
update: 'CHANGE',
destroy: 'DELETE'

reader: {
type: 'json',
root: 'user'

create: function(operation, callback, scope) {},
read: function(operation, callback, scope) {console.log('@userstorage: proxy reading...');},
update: function(operation, callback, scope) {},
destroy: function(operation, callback, scope) {}

but when I want to load the data via
`mystore.load();` only the "read"-method is called, without any call to the URL.
what am I doint wrong?


20 Jul 2011, 5:57 AM
Wouldn't it make sense to map your actionMethods to actual HTTP request methods?

actionMethods: {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy: 'DELETE'

EDIT: On another note, ScriptTagProxy is not an extension of AjaxProxy and does not know what to do with the actionMethods in the first place. You should probably have a look at the Code for AjaxProxy/RestProxy and ScriptTagProxy and write your own proxy class that combines them.

20 Jul 2011, 6:48 AM
unfort. I am not that good...