I’m relatively new to gwt and I have a problem using JsArrayInteger. Here is my code:
package com.google.gwt.sample.stockwatcher.client;
public class StockWatcher implements EntryPoint {
JsArrayInteger a;
public void onModuleLoad() {
a = (JsArrayInteger) JsArrayInteger.createArray();
a.push(1);
a.push(2);
a.push(4);
a.push(5);
test();
}
public static native void test() /*-{
var p = [1,2,3,4,5,6];
var q = this.@com.google.gwt.sample.stockwatcher.client.StockWatcher::a;
alert(q);
alert(p);
}-*/;
}
The result is ‘undefined’ and [1,2,3,4,5,6] instead of [1,2,3,4,5] and [1,2,3,4,5,6]. I want to use the field a and work on that array (pass it to a third party library).
The tutorial http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsJSNI.html didn’t explain how to use the default JavaScriptObjetcs. Does somebody find the error?
Best regards,
Michael
Note that this method is
static, but you are referring tothis. Either pass in an instance and use that instead ofthis, or change the method to not bestatic.