On Thu, Jan 24, 2013 at 2:14 PM, Sergio Sánchez Maffet <s.sanc...@gmx.net>wrote:
> Thank you Derrell for your quick response,
>
> Ok I understand your point. I've looked into the qooxdoo implementations
> and I found this here in qx.bom.request.Jsonp:
>
>
> callback: function(data) {
> if (this.__disposed) {
> return;
> }
>
> // Signal callback was called
> this.__callbackCalled = true;
>
> // Sanitize and parse
> if (qx.core.Environment.get("qx.debug")) {
> data = qx.lang.Json.stringify(data);
> data = qx.lang.Json.parse(data);
> }
>
> // Set response
> this.responseJson = data;
>
> // Delete global reference to this
> this.constructor[this.__id] = undefined;
>
> this.__deleteCustomCallback();
> },
>
> The lines above, inside the second if statement are causing my problem.
> Before the mentioned if, the data object is fine and includes Date
> objects, but the debug code is "sanitizing" the date object in the map back
> to a string literal.
>
> This seems to be a bug, because it does not behave in debug mode equally
> to non debug mode.
>
> From my understanding the following is happening:
>
> 1. Request is send
> 2. Server answers with a jsonp response e.g. somecallback({ ... myproperty
> : new Date ...});
> 3. This is parsed and executed by the script element, therefor Date object
> should be present. The qooxdoo callback method converts the date object
> back to a string only in debug mode.
>
> This seems to be a bug for me.
> If the behaviour is to have a json object with date literals, then this
> does only work in debug mode.
> If not, if the content of the callback should be used as it is given by
> the script element, then this sanitizing is a bug that only affects in
> debug mode.
>
> So this seems to be in either case a bug, is my conclusion right or do I
> miss other side effects?
>
I have no idea why that sanitize code was put there, but to catch exactly
this sort of "bug" you're encountering (having a Date object that can't be
properly stringified and parsed without replacer and reviver functions). If
you're using jsonp, then you can not assume that the server will support
date objects in the same way that you expect them to be handled, so what
you send to the server in a request may not be interpreted correctly, and
what the server sends back to you in a response may well not be in a format
that your reviver function, even if you had one, would handle. The Jsonp
class is for generic use. If you have a specific server/client interaction
that you require, you'll likely want to subclass and customize.
> Also another possible bug is present, I have noticed, that the above
> callback is called exactly 10 times, called from a remote table model.
> Need also to figure out what is happening, seems not to be in my code...
> will come back soon with this.
>
That's a well-known problem for which there are existing bug reports. There
have also been a number of recent discussions on the mailing list about
this problem.
Cheers,
Derrell
------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel