The '_1_g$' indicates you are in super dev mode - does it work correctly when fully compiled to JS (draft or no)? I saw a problem in this area a few weeks ago.
-- Also, can you post the full definition for MyObject?
I agree with Alberto though, your printObj doesn't make any sense as is - it is calling the java toString() method on the object rather than serializing to JSON, or do you expect MyObject.toString() to return a json string?
On Friday, May 15, 2015 at 2:54:32 AM UTC-5, Alex W wrote:
On Friday, May 15, 2015 at 2:54:32 AM UTC-5, Alex W wrote:
I tried that, it gave me the same result, but your post gave me an idea. I set printObj up to assign a variable with it's data, so the last element in the list would get it.
Inside
ns.printObj = function(data) {
ns.foo = data;
}
Then I typed ns.foo into chrome's dev console so I could introspect the object that way. It turns out that the data is there, but it's all mangled with funny symbols like
kRg_g$ { mySymbol_1_g$ } etc. Can anyone on the GWT team weigh in and tell me how to unmangle it, such that I can write my views in JS and my model/controller in java?
On a side note, it would be really nice if there was a nice no-brainer way of serializing/deserializing between JSON and Java Objects exposed to gwt users. This has always been a huge feature hole in gwt imo.
Thanks
Alex
On Friday, May 15, 2015 at 5:09:50 PM UTC+10, Alberto Mancini wrote:the object has properties but when you concatenate a string with your object in the line"We can't see the obj's properties, only:" + objyou are essentially converting obj to a string through obj.toString() so yournative method does not receives the object obj but a string.try this passing just obj to printObj.A.On Fri, May 15, 2015 at 8:57 AM Alex W <alexwh...@gmail.com> wrote:Wouldn't the object have a bunch of JSON properties then?
On Friday, May 15, 2015 at 4:47:39 PM UTC+10, Alberto Mancini wrote:Hi,
you are converting obj to a string before calling printObj: "We can't see the obj's properties, only:" + objHope this helps.Alberto.On Fri, May 15, 2015 at 7:52 AM Alex W <alexwh...@gmail.com> wrote:We are usingJSInterop in GWT2.8. In one of our RPCs we have some code like this that passes our java object to JS:
onSuccess(List<MyObject> objs) {
for (MyObject obj: objs) {
jsCode.printObj("We can't see the obj's properties, only:" + obj);
}
}
The definition of jsCode looks like this:
ns.printObj = function(obj) {
console.log(JSON.stringify(obj));
}
In the console we get back:
We can't see the obj's properties, only:our.ns.type.MyObject@16
The value object has been annotated as @JsType. Anything else we need to do?
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment