[Dojo-interest] dojo.store.JsonRest server side implementation with spring 3.x examples
Nick Fenwick
neek at nickfenwick.com
Fri Aug 5 00:36:03 EDT 2011
On 08/03/2011 04:38 AM, Bo Lorentsen wrote:
> On 07/31/2011 07:43 PM, Kitson Kelly wrote:
>> I started a tutorial today... I will work on it some more this
>> evening: http://docs.dojocampus.org/quickstart/rest. I will try to
>> clarify a lot of the Dojo conventions I am aware of as well as
>> provide some good examples. I am sure there are other conventions
>> out there, but then others can add as they see fit...
> Regarding POST in REST:
>
> You write the that one need to include an "Location:" header in the
> response, but why is this needed and nor just the inserted data ? In
> my server implementation I send a single object back, that containings
> all the data provided by the store, supplied by some of the data
> provided by the back-end too(like auto fields in DB's).
Just to mention, my experience with dojox.data.JsonRestStore (not the
new dojo.store implementation) was that it sometimes follows the spec
closely, and it can be hard to spot exactly what one has done wrong when
things don't seem to perform the way you expect. As I recall, If you
write a server side implementation that handles POST to create a new
entity, but does not return the Location header, the JsonRestStore
simply ignores the returned data and doesn't handle the new object
correctly.
On this subject of POST,
http://dojotoolkit.org/reference-guide/dojox/data/JsonRestStore.html
briefly mentions that "The JsonRestStore follows RFC 2616
(http://www.ietf.org/rfc/rfc2616.txt) whenever possible to define to
interaction with server." .. then later "If your server wants to assign
the URL/location for the newly created item, it can do so by including a
Location header in the response" .. and that rfc document on page 54:
If a resource has been created on the origin server, the response
SHOULD be 201 (Created) and contain an entity which describes the
status of the request and refers to the new resource, and a Location
header (see section 14.30).
The dojo docs on imply that you "can" include a Location header, but the
RFC spec dictates it as recommended (SHOULD), and without it the dojo
store may not react to the newly created item when the HTTP POST request
returns, for example telling a connected DataGrid about the newly
created item.
The devil is often in this kind of detail :)
Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.dojotoolkit.org/pipermail/dojo-interest/attachments/20110805/d9b6a920/attachment.htm
More information about the Dojo-interest
mailing list