GWT 2.7 JsInterop member function with custom objects.

95 views
Skip to first unread message

confile

unread,
Nov 2, 2014, 12:55:38 PM11/2/14
to google-web-tool...@googlegroups.com
I use JsInterop to map Kinetic.js I created the following interfaces:

@JsType(prototype = "$wnd.Kinetic.Node")
public interface KNode {
}


@JsType(prototype = "$wnd.Kinetic.Container")
public interface KContainer extends KNode {

/**
* Add a node to this container.
* @param child A child node
*/
public void add(KNode child);
}

@JsType(prototype = "$wnd.Kinetic.Stage")
public interface KStage extends KContainer {

public static abstract class Statics {

public static native KStage create(Element stageContainer, int stageWidth, int stageHeight) /*-{
return new $wnd.Kinetic.Stage({
container : stageContainer,
width : stageWidth,
height : stageHeight
});
}-*/;

}
}


@JsType(prototype = "$wnd.Kinetic.Layer")
public interface KLayer extends KContainer {

public static abstract class Statics {

public static native KLayer create() /*-{
return new $wnd.Kinetic.Layer();
}-*/;

}
}


In my Java class I call:

KStage stage = KStage.Statics.create(stageContainer, stageWidth, stageHeight);
KLayer baseLayer = KLayer.Statics.create();
stage.add(baseLayer);

Running in SDM I get the following error in the last line (stage.add(..)):

SEVERE: (TypeError) : 'undefined' is not a function (evaluating 'this.stage_0_g$.add_219_g$(this.baseLayer_0_g$)')com.google.gwt.core.client.JavaScriptException: (TypeError) : 'undefined' is not a function (evaluating 'this.stage_0_g$.add_219_g$(this.baseLayer_0_g$)')
at Unknown.wrap_4_g$(Unknown Source)
at Unknown.entry0_0_g$(Unknown Source)
at Unknown.anonymous(Unknown Source)


Did I miss something here?

Jens

unread,
Nov 2, 2014, 2:00:19 PM11/2/14
to google-web-tool...@googlegroups.com
Have you forgot to use the -XjsInterop parameter when starting SDM?

-- J.

confile

unread,
Nov 2, 2014, 3:31:05 PM11/2/14
to google-web-tool...@googlegroups.com
@Jens you where right I was missing the -XjsInterop in SDM I had it only set for compile. Thank you.
Reply all
Reply to author
Forward
0 new messages