PDA

View Full Version : Wrong response processing in Direct?



el.weilando
26 Jun 2011, 11:14 AM
REQUIRED INFORMATION


Ext version tested:


Ext 4.0.2



Browser versions tested against:


FF3 (firebug 1.3.0.10 installed)
Safari 4



Description:

I spending many, many hours into understanding of Ext.Direct. Now I'm not realy sure if I always don't understand this part of extjs or if there are just some bugs.

When I append a child to a tree I must call sync manualy. I think it's also an bug http://www.sencha.com/forum/showthread.php?138166-Ext.data.TreeStore-bug

After sync the server sends this




node.appendChild({
text:'testdsadsad',
leaf: true
});

{"action":"RPCAction","method":"createFolderNode","data":[{"id":"","text":"testdsadsad","leaf":true,"parentId":"222524db-a76f-4868-9c44-95502cd5c376","index":4,"depth":2,"checked":null}],"type":"rpc","tid":6}
When i send something back like this




{
"tid": 5,
"action": "RPCAction",
"method": "createFolderNode",
"result": [
{
"id": "",
"text": "ichbinneutesthahaha",
"leaf": false,
"parentId": "06b3abd9-b9e1-48d9-91a2-44726d954b59",
"index": 3,
"depth": 2
}
],
"type": "rpc"
}

All values can be different from the request except for the id. the differences between request and answer will be applied to the tree, when id is the same.

If the id is different, nothing happen. The record are still phantom or dirty.

But should not set the server the id while calling create function? and should not be used this server-id by the client?

The crazy thing is, wenn I append an child without set the id-property in model. the store set this record to phantom and get it back while calling getNewRecords(). If I calling sync(), create-api is beeing applied.

When I set the id in the server-answer and send this back. The appended child will never be changed, because the id is different.

But if I set the id-property in appendChild(),



node.appendChild({
id: Ext.id(),
text:'testdsadsad',
leaf: true
});


The server don't set phantom an get me the record in getUpdateRecords() back - although is should be a new record. If I calling sync(), update-api is beeing applied.

I think is same problem like in this post http://www.sencha.com/forum/showthread.php?137311-processResponse-is-wrong-in-Ext.data.proxy.Server



Test Case:




Ext.define('ip.docmanager.folderModel', {
extend: 'Ext.data.Model',
idProperty: 'id',
fields: [{
name: 'id',
type: 'string'
},{
name: 'text',
type: 'string'
},{
name: 'leaf',
type: 'bool'
}]
});

this.folderStore = Ext.create('Ext.data.TreeStore', {
model: 'ip.docmanager.folderModel',
autoSync: true,
storeId: 'folderStore',
proxy: {
type: 'direct',
api: {
create : ip.docmanager.api.RPCAction.createFolderNode,
read : ip.docmanager.api.RPCAction.getFolderNodes,
update : ip.docmanager.api.RPCAction.updateFolderNode,
destroy : ip.docmanager.api.RPCAction.removeFolderNode
}
},
autoLoad: true
});


this.folderTree = Ext.create('Ext.tree.Panel', {
collapsible: true,
floatable: true,
split: true,
width: 200,
height: 150,
store: this.folderStore,
autoRender: true,
rootVisible: false,

});

},



HELPFUL INFORMATION



Operating System:


OSX