ThorstenSuckow
20 Oct 2009, 2:14 AM
Putting ids/data into the data array for a delete/operation is a good thing - it automates a lot for you when, for example, working on a set of records that represent application settings, or even entries in a larger grid.
However, there seems to be one shortcoming: The Server Responses and the way the Ext.Direct API deals with them
In general, there are 5 cases the API has to properly respond to.
Updating data server side:
====================
1) Data with id [id] was successfully updated
2) Data with id [id] was successfully updated, but data with id [id2] could not be updated
3) An exception was thrown, the state of the update is unknown
4) A timeout occured, the response was empty
5) No data was successfully updated
Cases 3, 4, 5 can be summed up and treated equally. However, case 1 and 2 need special treatment.
Case 1:
======
Let's say I'm updating the records with the ids 1 and 2. The request sends the data array to the server. The server is able to update both data successfully.
The response should include the following data:
result: {
success : true,
updated : [1, 2],
failed : []
}
Case 2:
======
Let's say I'm updating the records with the ids 1 and 2. The request sends the data array to the server. The server is able to update record with id 1 successfully, bit updating record with id 2 failed:
The response should include the following data:
result: {
success : true,
updated : [1],
failed : [2]
}
The same applies for deleting records - sending back the ids where the action succeeded and simultaneously giving infomration about the ids where the action failed.
The Ext.Direct API should then (as a standard behavior) process the updated/failed properties and commit/rollback actions taken on the records with the given ids.
However, there seems to be one shortcoming: The Server Responses and the way the Ext.Direct API deals with them
In general, there are 5 cases the API has to properly respond to.
Updating data server side:
====================
1) Data with id [id] was successfully updated
2) Data with id [id] was successfully updated, but data with id [id2] could not be updated
3) An exception was thrown, the state of the update is unknown
4) A timeout occured, the response was empty
5) No data was successfully updated
Cases 3, 4, 5 can be summed up and treated equally. However, case 1 and 2 need special treatment.
Case 1:
======
Let's say I'm updating the records with the ids 1 and 2. The request sends the data array to the server. The server is able to update both data successfully.
The response should include the following data:
result: {
success : true,
updated : [1, 2],
failed : []
}
Case 2:
======
Let's say I'm updating the records with the ids 1 and 2. The request sends the data array to the server. The server is able to update record with id 1 successfully, bit updating record with id 2 failed:
The response should include the following data:
result: {
success : true,
updated : [1],
failed : [2]
}
The same applies for deleting records - sending back the ids where the action succeeded and simultaneously giving infomration about the ids where the action failed.
The Ext.Direct API should then (as a standard behavior) process the updated/failed properties and commit/rollback actions taken on the records with the given ids.