PDA

View Full Version : Store write event not firing



bocockli
27 Jul 2009, 6:04 AM
I have set up a generic store with JSON readers and writers:


var store = new Ext.data.Store({
id : 'recordID',
autoSave : true,
reader : new Ext.data.JsonReader({
root : 'policy',
successProperty : 'success',
idProperty : 'recordID'
}, policyRecord),
writer : new Ext.data.JsonWriter({
encode : true,
writeAllFields : true
}),
proxy : new Ext.data.HttpProxy({
api : {
read : 'vault?cmd=getPolicy',
create : 'vault?cmd=updateStore&store=policy&action=create',
update : 'vault?cmd=updateStore&store=policy&action=update',
destroy : 'vault?cmd=updateStore&store=policy&action=delete'
}
}),
listeners : {
write : function(store, action, result, res, rs) {
console.log('WRITE', arguments);
},
The post works, the Servlet returns a HTTP status of 200 OK. The response returns the following JSON

{"success": "true", "policy":[{"serverID":"1", "clientID":"19"}]}

The store 'write' event is not firing - I need this to update the client recordID with the server recordID. With event tracing I am seeing the following sequence:

store.insert(0, formRecord);
-> add event
-> beforewrite event
-> POST http:..... OK 200
storeCommitChanges();
->update event

Where's the write event? What am I missing here?

Thanks, Len

bocockli
28 Jul 2009, 12:42 AM
Ok, so the answer is to attach the 'write' listener to the HttpProxy, not the Store.

Whether this is a bug or not I am not sure, but it seems the 'write' event from HttpProxy is not being cascaded through to the Store.....



proxy : new Ext.data.HttpProxy({
api : {
read : 'vault?cmd=getPolicy',
create : 'vault?cmd=updateStore&store=policy&action=create',
update : 'vault?cmd=updateStore&store=policy&action=update',
destroy : 'vault?cmd=updateStore&store=policy&action=delete'
},
listeners : {
write : function(store, action, result, res, rs) {
console.log('WRITE', arguments);
}
}
}),

damien.corpataux
27 Mar 2012, 7:25 AM
Hi, i'm trying the same in ExtJS and i'm facing the same problem.

The 'write' event is documented in Store class, but does not fire.

The 'write' event is not documented in Proxy classes, and does not fire neither...