How to expose class functionality in GWT

后端 未结 2 591
無奈伤痛
無奈伤痛 2021-01-14 04:49

I have a class library written in Java and want to convert it to Javascript. All methods are pretty simple and mostly have to do with manipulating collections. I have this o

2条回答
  •  自闭症患者
    2021-01-14 05:43

    You have exposed only instance of the GameControl. If you want to expose other methods, you'll have to expose them as well. For example:

     public native void expose()/*-{
            var control = this.@game.client.GameEntryPoint::_gameControl;   
            var gameInstance = {
                gameControl: control,
                isEmpty:function(param){
                  control.@game.client.GameEntryPoint::isEmpty(*)(param);   
                }  
    
            }
    
    
            $wnd.game = gameInstance;
        }-*/;
    

    Also there is a framework called gwt-exporter, it might make things easier for you

提交回复
热议问题