PDA

View Full Version : How does Rest and Ajax proxy figure out the server generated id?



tonyx
5 Sep 2011, 10:49 AM
After creating and saving a new model object on the client, a model configured with REST proxy will automatically send HTTP POST request to /model/ url. However, what format must the server's response be in order for Ext Js to figure out the server generated id of the newly synced object? I couldn't find the documentation for this in either Ajax proxy or Rest proxy. Or is updating the model id the responsibility of the user?

One more thing. how does Ext Js determine whether to send a PUT or a POST request? Is it as simple as checking if the idParam is valid and exists or is there something more complex going on?

Thanks!

lisper
5 Sep 2011, 2:54 PM
After creating and saving a new model object on the client, a model configured with REST proxy will automatically send HTTP POST request to /model/ url. However, what format must the server's response be in order for Ext Js to figure out the server generated id of the newly synced object? I couldn't find the documentation for this in either Ajax proxy or Rest proxy.

Neither could I, but I reverse-engineered the restful example code and it seems that the correct response is whatever it would have been if it had been a GET method, i.e. the server just echoes the data back to the client with the id parameter added. Empirically this seems to work.


One more thing. how does Ext Js determine whether to send a PUT or a POST request? Is it as simple as checking if the idParam is valid and exists or is there something more complex going on?

Nope, that's pretty much it (AFAICT).