I'm talking about POST of JSON content, and the nesting of the JSON object. Its not an issue of handling a POST of a form.
My point is that the Ext framework includes several components that are 2-way (reader & writer) AJAX components. So if I'm handling a form, I would like to handle it the same way reading and writing.
So according to the Ext docs, my retrieve action must put the form elements in the "data" object. So I do this:
{
"data":{"SSN":"111222233","birthDate":"1967-02-22T00:00:00","firstName":"SARAH","lastName":"SNIDER","zip":"10022"},
"success":true
}
The Form expects the data in that format. However, when it posts via AJAX, the JSON loses the "data" nesting and goes back as:
SSN 111222233
birthDate 1967-02-22T00:00:00
firstName SARAH
lastName SNIDER
zip 10022
I would expect to have the ability to POST it as:
data.SSN 111222233
data.birthDate 1967-02-22T00:00:00
data.firstName SARAH
data.lastName SNIDER
data.zip 10022
Since this example uses JSON to read but a plain HTTP form to post, let me give the example with JSON both ways.
The problem is even more clear when using the HttpProxy with a JsonReader for an editable grid.
var
proxy = new Ext.data.HttpProxy({
api: {
read : 'rxProfileRetrieve.emr',
create : 'rxProfileCreate.emr',
update: 'rxProfileUpdate.emr',
destroy: 'rxProfileDelete.emr'
}
});
var reader = new Ext.data.JsonReader({
totalProperty: 'total',
successProperty: 'success',
idProperty: 'id',
root: 'extGridData.entries'
}, [
{name: 'id'},
{name: 'drugDesc', allowBlank: false},
{name: 'symptomDesc'},
{name: 'prescriberName'},
{name: 'rxNum'},
{name: 'fillDate'},
{name: 'qty'},
{name: 'qtyPerDay'},
{name: 'refillDate'},
{name: 'newRxDate'}
]);
var
writer = new Ext.data.JsonWriter({
encode: true,
writeAllFields: true,
listful: false
});
The JSON for retrieve is:
{"extGridData":{"entries":["{\"id\":\"1\",\"drugDesc\":\"Xanax - 0.25mg\",\"symptomDesc\":\"Anxiety\",\"prescriberName\":\"Dr. Joe Smith\",\"rxNum\":\"1230011\",\"fillDate\":\"\",\"qty\":\"45\",\"qtyPerDay\":2,\"refillDate\":null,\"newRxDate\":\"\"}"],"selectedId":null,"selectedObject":null}}
But the Grid / HttpProxy serializes it back out as:
{"entries":["{\"id\":\"1\",\"drugDesc\":\"Xanax - 0.25mg\",\"symptomDesc\":\"Anxiety\",\"prescriberName\":\"Dr. Joe Smith\",\"rxNum\":\"1230011\",\"fillDate\":\"\",\"qty\":\"45\",\"qtyPerDay\":2,\"refillDate\":null,\"newRxDate\":\"\"}"],"selectedId":null,"selectedObject":null}
Where is "extGridData" top level node? It is not there, because I'm using "root" node of "extGridData.entries" and there is no way to easily wrap it with "extGridData" on the way out with the JsonWriter. So its not a Java server-side issue. It's an issue of not being able to preserve the nested structure of the JSON object graph properly with the Ext API. I serialize and deserialize to and from the same object, so having the top node discarded is problematic.
Thanks,
mjc
PS: Sorry for the poor formatting, this forum editor is not friendly about preserving things.