Hi Andy,

Please use the mailing list  [email protected]  for
requesting help with your code. This mailing list is to discuss about the
development of GWT itself.

Hint to solve your issue: your method TestObj.member1() returns nothing...
add "return this;" should solve your problem.

Julien


On Sun, Jul 13, 2014 at 4:47 PM, andymel <[email protected]> wrote:

> Hi,
>
> I am trying to find a bug in my first gwt project. I wrote another little
> project with just 3 classes to show just the behavior I don't understand.
> I try to initialize objects in JavaScript (need that to use an existing js
> script in my (new) Java Code).
>
> For my test I simply want to get an Object with a number array and read
> that...but the call of get(i) leads to 'Something other than a double was
> returned from JSNI method'.
>
> Can anybody point me in the right direction please!?
>
> Thanks a lot!! :)
>
> JavaScript:
> var TestObj = {};
>
> /* helper function to get such an object
>  * not possible to get it directly?!*/
> function getMem1(x,y){
> return new TestObj.member1([x,y]);
> }
>
> TestObj.member1 = function(p){
> // should be an array of two floating point values (saved as double in
> java)
> this.p = p;
> }
>
> My Java Object:
> public class TestObjJava {
>
> private double x;
> private double y;
>  public TestObjJava(double x, double y) {
> this.x = x;
> this.y = y;
> }
>
> public native TestObjJS getAsJSObj() /*-{
> return $wnd.getMem1(this.x, this.y)
> }-*/;
> }
>
> My JavaScriptObject
> public class TestObjJS extends JavaScriptObject {
>
> protected TestObjJS() {}
>
> public final native JsArrayNumber getP() /*-{ return this.p; }-*/;
> }
>
> The code that leads to the error:
> public void onModuleLoad() {
>  TestObjJava jObj = new TestObjJava(12, 23);
> TestObjJS jsObj = jObj.getAsJSObj();
>  JsArrayNumber p = jsObj.getP();
>  System.out.println(p);
>  for(int i=0; i<p.length(); i++){
> System.out.println(i+": "+p.get(i));
> }
> }
>
> The full error message:
>
> onModuleLoad() threw an exception
> Exception while loading module andymel.tests.gwttests.client.GWTTests. See
> Development Mode for details.
>
>
> java.lang.reflect.InvocationTargetException
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:411)
> at
> com.google.gwt.dev.shell.OophmSessionHandler.loadModule(OophmSessionHandler.java:200)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:526)
> at
> com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:364)
> at java.lang.Thread.run(Unknown Source)
> Caused by: com.google.gwt.dev.shell.HostedModeException: Something other
> than a double was returned from JSNI method
> '@com.google.gwt.core.client.JsArrayNumber::get(I)': JS value of type
> undefined, expected double
> at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:112)
> at
> com.google.gwt.dev.shell.ModuleSpace.invokeNativeDouble(ModuleSpace.java:238)
> at
> com.google.gwt.dev.shell.JavaScriptHost.invokeNativeDouble(JavaScriptHost.java:59)
> at com.google.gwt.core.client.JsArrayNumber$.get$(JsArrayNumber.java)
> at andymel.tests.gwttests.client.GWTTests.onModuleLoad(GWTTests.java:30)
> ... 9 more
>
>
>  --
> 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/e3383695-7f7f-46f1-b346-25f2dcc338e3%40googlegroups.com
> <https://groups.google.com/d/msgid/google-web-toolkit-contributors/e3383695-7f7f-46f1-b346-25f2dcc338e3%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/CABb_3%3D7bLKekAtuJa5GQw4068MhrcK9%3D5iL%3DT4tFvGL-x0mM0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to