Opened 13 years ago

Closed 13 years ago

#8475 closed defect (wontfix)

dojox.rpc.jsonrest does not pass return arguments in commit()'s onComplete handler

Reported by: John Locke Owned by: Kris Zyp
Priority: high Milestone: 1.3
Component: Dojox Version: 1.2.3
Keywords: Cc:
Blocked By: Blocking:


Related to #8418, but this time, wanting essentially the same fix for the onComplete function

When you call the JsonRestStore?.save() method and pass an onComplete function, that function does not receive any arguments.

Expected result: Should receive the response from XHR.

Suggested patch:

--- a/dojox/rpc/JsonRest.js
+++ b/dojox/rpc/JsonRest.js
@@ -105,7 +105,7 @@ dojo.require("dojox.rpc.Rest");
 						return value;

Change History (4)

comment:1 Changed 13 years ago by Adam Peller

Component: GeneralDojox
Owner: changed from anonymous to Kris Zyp

comment:2 Changed 13 years ago by Kris Zyp

Milestone: tbd1.4

It should be noted that the Dojo Data Write API says that "No parameters are generally passed to the onComplete". I don't mind adding the value, but it will have to wait for 1.4.

comment:3 Changed 13 years ago by John Locke

Hmm. Okay, I found the API document specifying this. So if this is not a supported way, what would the correct approach be?

I'm using the save hander to PUT data changed in the client side back to the server. The server merges this with other data, possibly coming from other sessions, and sends back the resource as the response to the PUT request.

The problem I'm having is that when I call the JsonRestStore?.save() method, it creates a PUT request for each changed item. Naturally, each response fires the onComplete method. Some of these responses are different from the request, in that the data on the server may get merged into the response (and the server handles authorizing what the client is allowed to change, so its response is correct, regardless of the request). So what I want to do is update the client-side data with changes merged from the client and server.

With this patch, it works nicely--JsonRestStore? is doing everything I need it to do, and firing the onSet notification. The other alternative I can think of is to trigger a reload of the store with an additional GET of that item--but the problem is, knowing which item has been refreshed!

I did look around for some function I could dojo.connect to to be able to intercept the response. I didn't find anything useful, and this approach seemed far more elegant. Is there a more favored approach to what I'm trying to do?

comment:4 Changed 13 years ago by Kris Zyp

Milestone: 1.41.3
Resolution: wontfix
Status: newclosed

After further discussions, it turns out that JsonRestStore? already meets the needs of this use case with it's automatic object updating capabilities. In addition, adding the value to onComplete would be rather inconsistent because it would only return the last value in the transaction.

Note: See TracTickets for help on using tickets.