> I believe it was in plans with @JsConvert – see slides 67 – 69. 
> https://docs.google.com/file/d/0ByS1wxINeBWjeGYxbkJpamxFZ28/edit
>

I think this is more meant to be used with non-native JsTypes. When you 
have a JsType implemented in Java and some JavaScript gives you JS through 
the Java object's public JS api. That way you can simply generate a 
delegate method that wraps the Js Array and provides the Java collection 
API on top of it.

However if you use native JsTypes together with JSON.parse() for convert 
JSON back to JavaScriptObjects you are only dealing with a naming 
convention and nothing more. Basically JSON.parse() sees your server 
generated JSON and will construct JS objects natively. Given that 
JSON.parse() only understands JS Objects, JsArrays and primitives the 
native JsType you will cast the result of JSON.parse() into, can also only 
have these types in order to access the underlying data. So if your server 
REST implementation serializes a Map as two JSON arrays (one for keys, one 
for values) then your native JsType also needs two JsArray fields in order 
to access them. The only thing you can do is define a @JsOverlay method 
that returns a Map implementation that wraps the two JsArrays and then use 
that @JsOverlay method in your code to get a Map view.

Given that you can only modify native JSON.parse() behavior to a limited 
extend I don't see any other way how a native JsType could transparently 
add an adapter around JsArrays in a configurable way (different REST server 
implementations might serialize maps in different ways) other then using 
@JsOverlay methods.


-- J.

-- 
You received this message because you are subscribed to the Google Groups "GWT 
Contributors" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit-contributors+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/8e4d0bdb-8dde-45dd-a166-e132efbb1750%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to