PDA

View Full Version : is this a bug? (JsonWriter)



Digitalman
23 Nov 2009, 10:05 PM
Given the following:



var writer = new Ext.data.JsonWriter({
writeAllFields: false
});

var proxy = new Ext.data.HttpProxy({
api: {
create : 'mileage/vehicles/create',
read : 'mileage/vehicles/read',
update : 'mileage/vehicles/update',
destroy : 'mileage/vehicles/destroy'
}
});


I'm wondering if something is wrong with writeAllFields because I'm seeing the entire record in the post (see attached image).

evant
23 Nov 2009, 10:13 PM
I'd say not. You're doing a create.

writeAllFields only applies to records that already exist, where you only want to send the changed fields. In the case of creation, every field has "changed", because it never existed!

Digitalman
24 Nov 2009, 7:55 AM
hmmm, you're right. I didn't notice. I think I didn't see it because I was actually performing an update but it went through as a create instead. Now I have to figure out why it issued a create and not an update.

Mike Robinson
24 Nov 2009, 8:12 AM
A "create" will happen when the record was added to the store. It is a so-called phantom record. When the create completes, the actual primary-key value must be returned as part of the host's response, and the phantom key-values are replaced.

Look at the execute() method, and its surrounds, in Ext.data.Store. (I spent way-y-yy too much time poking around these parts, trying to "get the damm thing to work" with our somewhat quirky ColdFusion. Learned a whole lot more about it than I wanted to.)

Digitalman
25 Nov 2009, 8:16 AM
It doesn't appear that it's an issue with create itself but with the grid and editing a field. I've tried this several times with diff. configs but they all lead to the create being called when I'm actually updating a field. My understanding is that when a field in a grid is edited, when you click off the field, the grid is supposed to tell the store that an update is needed. For whatever reason, an update is not triggered, a create is. I'm still trying to figure out if I have something configured wrong, or I'm missing something, or if there really is some bug (which I highly doubt, but would never rule out).

Mike Robinson
25 Nov 2009, 9:22 AM
Most likely, you've got an issue with the primary-keys. The data member contains the records and each of them has a property to indicate if it's considered "phantom."

Track the status of your records through a complete request: from when records arrive from the host, through everything that happens to them subsequently. Check very carefully that the primary-key field name is specified exactly. You have an underlying bug that probably is manifesting itself very far away from the actual root cause of the problem.

qinglan_g
1 Dec 2009, 8:22 AM
Digitalman, have you figured out the issue you posted?

I have got the exact same error as you experienced. It seems that the the "create" url is called every time I do an update. I did check to make sure that the phantom of the record is "true" which means that the data already exists in the server side. So this factor can be ruled out.

Please post your find if you figured it out.

Thanks.



Qinglan

frrogoy
14 Apr 2010, 5:20 AM
Has anyone ever figured this out? I can't find documented what to return on the phantom create, and in what format. Apparently if you don't return at least a dummy key, the store thinks the record still hasn't been created. Then when you try to update the record, it does another create.
I'm not saying it isn't documented, just I can't find it...

ToZie
10 Jul 2010, 1:10 PM
after some trying i figured out that Ext.data.Store will allways fire create requests on updates when idProperty is set to 'Id'. Changing this Property to something different, like 'RecId' (and changing the data too, of curse) solves the Problem for me - i would consider this a Bug.

lg

Torsten