Rudriko wrote:
> Hello,
>
> I'm currently trying to use a JSon object in order to save a qx "Label"
> object in MySQL db.
> And then i'd like to "restore" this label.
>
> This is an example:
>
> My browser do send this JSon to MySQL through request and my php function
> (...)
> var serialize = object.serialize();
> var json = qx.util.Json.stringify(serialize);
> this.MyRequester.senddata(json);
> (...)
>
> and then when my browser request for the object i try to do with the server
> answer that looks like :
> {classname:"Label" etc...)
> (...)
> var myload_object = qx.util.Json.parseQX(responseText);
> (...)
> There's no error, but "myload_object" doesn't appears on my page.
>
Mh...
1. Json.parseQx() simply parses Json into JS. You could just as well use
Json.parse(). There is nothing "Qx"-ish about it. That means, all you
get is a JS built-in data object (map, array,...) - that's all Json
supports. You'll never get a qooxdoo object this way.
2. The qx.core.Object.serialize() method is highly experimental. You
should check the implementation to see if all information you want is
included for a given object instance. But in any case, you should be
clear that references to other objects within this object will not be
included recursively (only their hash value), so you will in general not
be able to restore these references. Basically, that means that you can
only serialize primitive property values (strings, numbers, boolean and
arrays/maps thereof) that persist sessions. References to other qooxdoo
objects could only be restored within the same session.
3. To get a qooxdoo object back from a Json format you need to implement
your own interpreter function that parses the myload_object and
re-creates a qooxdoo object from it (e.g. by instantiating the proper
qooxdoo class, sets properties to corresponding values, etc.). This you
have to do on your own, and will work only under defined circumstances.
4. If you then have a proper qooxdoo object instance you can add it to
your current qooxdoo application. Only then will it appear on your page.
5. You might want to look at the CouchDB contrib project
(http://qooxdoo.org/contrib/project/couchdb), which is also concerned
with sending and reading Json to and from a database. Maybe they have
some helpful insights.
Thomas
> I probably miss something or misunderstand the point of parseQX, could
> please throw me on the right way ?
> Another terms for the question is : am i abble to save/restore QX objects so
> as to retreive all members (properties, methods, etc...)
>
> Thanks for every tips you could bring :)
>
> Kindly, Rudriko
>
>
>
>
>
>
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel