As Thomas, says it will be impossible to support passing any of the
collection interfaces directly through to JS code. You might think however,
that you could change the implementation of ArrayList to actually be a JS
Array. I don't think this is possible because an instance ArrayList needs
to fulfill the Java contract of being able to know which interfaces it
implements. This is done by having special meta data attached to the object
prototype. The minute you start touching the Array prototype you have the
potential of incompatibility with existing JS code.
Having said that, it is totally possible to have a native JS array Interop
interface provide an adapter to make it look like a List. Below is a very
hacky way to do it using the Array interface I defined.
*private native *<E> List<E> asList(Array<E> a) */*-{
**l** = @java.util.ArrayList::new()()
**[email protected]::array <[email protected]::array>** = a;
return **l**;
}-*/*;
Array<String> jsArray = Array.*create*();
jsArray.push(*"val1"*);
jsArray.push(*"val2"*);
List lArray = asList(jsArray);
lArray.add(*"val3"*);
jsArray.push(*"val4"*);
--
You received this message because you are subscribed to the Google Groups "GWT
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.