If in your model is enough to have Collections/Lists based on ArrayList you
can easily convert from JsArrays to ArrayLists and vice-versa by using a
bit of JSNI since the ArrayList implementation in GWT relies on a
javascript array.

Take a look to this code used in the gwt-polymer-elements library (put
attention to asList and asArrayList methods)

https://github.com/manolo/gwt-api-generator/blob/master/lib/com/vaadin/polymer/Polymer.java#L522

- Manolo


On Mon, May 8, 2017 at 10:27 PM, Marcin Okraszewski <[email protected]>
wrote:

> Basically what we need it for is REST. Currently we use AutoBeans, but we
> want to change it because we need to pass the model to JS too; secondly
> AutoBeans generate a lot of code. We would like to still preserve shared
> model with the server. So, JsInterop seems the most natural choice, except
> it doesn't support collections. We mostly need List and Map. Switching to
> JsInterop with replacing Lists with some JS array view would be quite an
> effort. It would introduce that into our server logic too (by the shared
> model). And and you could even use Java's for each loop, as native JsType
> cannot extend non-JsType interfaces, so it could not extend Iterable (of
> course adapter could be instantiated for every list you want to iterate).
> Same for streams.
>
> Therefore we look for collection support in JsInterop, which was planned
> for "phase 2". If that was in our reach, we could help in getting it.
>
> Marcin
>
>
> On Monday, 8 May 2017 16:42:17 UTC+2, Ray Cromwell wrote:
>>
>> The adapter class adds overhead though and you need to convert into and
>> out of it every time you pass it to JS. At that point you may as well use
>> Java.util.List and write an adapter around JS array.
>>
>>
>> On Mon, May 8, 2017 at 7:10 AM Jens <[email protected]> wrote:
>>
>>> IMHO if you want a JavaScript array, set, map behave the same as a Java
>>> collection, so you can use it with other libraries, you should write an
>>> adapter class that implements the Java API and operates internally on the
>>> JavaScript data type.
>>>
>>> Basically do not rely on invisible magic. That could easily be
>>> implemented as a 3rd party project.
>>>
>>> -- 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 [email protected]
>>> .
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/google-web-toolkit-contributors/4d08f88c-ec88-4818-b778-
>>> 3e0e247f2e7e%40googlegroups.com
>>> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/4d08f88c-ec88-4818-b778-3e0e247f2e7e%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> 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 [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/google-web-toolkit-contributors/5e9868cd-35d6-
> 4f48-81b8-ef26ff791906%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/5e9868cd-35d6-4f48-81b8-ef26ff791906%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-web-toolkit-contributors/CAM28XAsesxqBxAS9Pjov%3DfPqy_u2raCEmFWLsO6OZN%3DbDrcpqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to