Thanks for all the answers

The Collection#toArray does not work in my case because dataTables.net are
a bit sensitive in the input. It stumbles upon java.lang stuff later on.
Here

> buttons = new String[] {"copyHtml5"};
>>
> while buttons2 is the correct one created with your previous suggestion.

   1.
   buttons:
      1. 0:"copyHtml5"
      2. __elementTypeCategory$:6
      3. __elementTypeId$:2
      4. java_lang_Object__1_1_1clazz:java_lang_Class_Class__V
      5. java_lang_Object_castableTypeMap:Object
      6. java_lang_Object_typeMarker:
      com_google_gwt_lang_Runtime_typeMarkerFn__V()
      7. length:1
      8. __proto__:Array[0]
   2. buttons2:Array[1]
      1. 0:"copyHtml5"
      2. length:1
      3. __proto__:Array[0]

About Array vs []
I am not js expert and looking for the difference I hit this
http://stackoverflow.com/questions/931872/what-s-the-difference-between-array-and-while-declaring-a-javascript-ar
Check this answer
http://stackoverflow.com/questions/931872/what-s-the-difference-between-array-and-while-declaring-a-javascript-ar/1273936#1273936

So I though if that could work with GWT and I tried it.

Also thanks for the link I bookmarked it.


On Thu, May 12, 2016 at 1:20 PM, Thomas Broyer <[email protected]> wrote:

>
>
> On Thursday, May 12, 2016 at 11:51:11 AM UTC+2, Vassilis Virvilis wrote:
>>
>> Thomas thanks,
>>
>> Wow I did this and it works. But it is crazy. Cr is for crazy. Kudos to
>> jsinterop guys though.
>>
>> @JsType(isNative = true, namespace = JsPackage.GLOBAL, name = "[]")
>>
>>
> You should probably use "Array" rather than "[]"
>
>
>> public interface CrJsArray<T> {
>>
>>     public void push(T value);
>>
>>     @JsProperty
>>     public int getLength();
>> }
>>
>>
>> I tried your suggestion to cast and __also works__ (eclipse complains
>> about but with (JavaScriptObject) (Object) my_native_object) it works and
>> it is definitely better.
>>
>
> Also, for converting from a java.util.Collection to an array, how about
> simply using Collection#toArray? (and then passing the array to JS through
> JsInterop)
>
>
>> Questions
>> 1) Is JavaScriptObject scheduled for deprecation?
>>
>
> Yes, it'll be replaced with JsInterop.
>
>
>> 2) Should a native type be able to extend JavascriptObject. Because right
>> now (2.8pre1) fails at run time. That would make casting a bit saner.
>> Should I report it somewhere?
>>
>
> This is probably on-purpose.
>
>
>> I tried to look for the reference you gave but I didn't find it. Wrong
>> keywords maybe...
>>
>
> I found this:
> https://groups.google.com/d/topic/google-web-toolkit/nmBAOX4vcSo/discussion
> Not exactly what I remembered, but touches similar points.
>
>
>>
>> On Thu, May 12, 2016 at 12:20 PM, Thomas Broyer <[email protected]>
>> wrote:
>>
>>> That question came up already in the forum or in GWT-Contrib (try to
>>> search the archive), and I seem to recall that Goktug said you could cast
>>> @JsType(isNative=true) objects to/from JavaScriptObject, so you could use
>>> JsArray (and JsonUtils.safeEval). I think you can also cast to/from an
>>> array of @JsType(isNative=true), so if you don't need to alter the size of
>>> the JS array you can then use the bracket operators on a Java array (and
>>> cast from/to a JavaScriptObject).
>>> This is only out of memory, please double check from the forum archives.
>>>
>>>
>>> On Thursday, May 12, 2016 at 10:47:51 AM UTC+2, Vassilis Virvilis wrote:
>>>>
>>>> Hi again,
>>>>
>>>> I am trying to convert a jre collection or build a jsArray with a
>>>> isNative=true type.
>>>>
>>>> Unfortunately this is not possible because JsArray requires
>>>> JavascriptObject which is invcompatible (complie time error) with native
>>>> classes.
>>>>
>>>> Any ideas?
>>>>
>>>> I looked on deep dive jsinterop from Ray Cromwell and it says that
>>>> there is not a clean way for jsinterop1 to align collections. Ok I get that
>>>> - but there must be a way even if not the nicest/cleanest one.
>>>>
>>>> Otherwise looks like I have to create my own @jsinteroped MyJsArray
>>>> which looks wrong.
>>>>
>>>> --
>>>> Vassilis Virvilis
>>>>
>>> --
>>> 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.
>>>
>>
>>
>>
>> --
>> Vassilis Virvilis
>>
> --
> 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.
>



-- 
Vassilis Virvilis

-- 
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.

Reply via email to