On 25 juin, 08:32, Bobby <[email protected]> wrote:
> Actually, i've just noticed that the ArrayHelper in the AjaxLoader
> module provides the same functionality. Question though, when calling
> the fromArray() method from within a JSNI method, what's the parameter
> signature that should be used? I'm not having any luck with fromArray
> (Lcom/google/gwt/core/client/JavaScriptObject;).
>
> I want to transform the following:
> public final native void setProperties(JsArray<Property> properties) /
> *-{
> this.setProperties(
> properties
> );
>
> }-*/;
>
> Into the following:
>
> public final native void setProperties(Property[] properties) /*-{
> this.setProperties(
> @net.ltgt.gwt.jscollections.client.JsArrays::fromArray(Lcom/
> google/gwt/core/client/JavaScriptObject;)(properties)
> );
>
> }-*/;
I'd personally use an intermediate setProperty(JsArray<Property>) and
call the fromArray in pure Java.
> But GWT complains about not being able to find the method with that
> signature.
http://code.google.com/webtoolkit/doc/1.6/DevGuideCodingBasics.html#DevGuideJavaScriptNativeInterface
links to http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/types.html#wp16432
which says to use:
...::fromArray([Lcom/google:gwt/core/client/JavaScriptObject;)
(properties)
(note the left square bracket before the L)
> Also, why are the ellipsis used?
to allow for uses such as fromArray("a", "b", "c") instead of fromArray
(new String[] { "a", "b", "c" })
> Do they have a special purpose in GWT?
No (and as with generics, it's hardly more than syntactic sugar, as
the "new String[]" is implied in the example above)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---