GWT Interface woes : Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined
GWT Interface woes : Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined
我正在使用 Libgdx 编写 GWT 应用程序,在 运行 时加载正确的 rest 库时遇到一些困难。
在我的核心 gradle 项目中,我定义了一个 "RestWrapper" 接口,允许访问平台特定的 REST 功能(对于 GWT,RestyGWT)。当 HTML5 启动器是 运行 时,它将其实现传递给核心项目中的 LibGDX 游戏 class。
然而,当 HTML5 项目是 运行 时,编译的 JS 会引发此错误:
Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined
问题似乎出在第一个界面 (PlatformWrapper) 上。
我知道 GWT 编译器在接口方面有点笨拙,我是否应该采取不同的方法从我的核心项目中 运行ning GWT 特定代码?
调用代码(在核心项目中:)
UserSessionToken token =client.getPlatform().getRestWrapper().getRestLogin().attemptLogin(userNameBox.getText(),passwordBox.getText());
接口(在核心项目中):
PlaformWrapper
public interface PlatformWrapper {
public RestWrapper getRestWrapper();....
RestWrapper
/* Platform independent wrapper for REST services */
public interface RestWrapper {
public RestLogin getRestLogin();....
实施(在 HTML5 项目中):
PlatformWrapper(顶级)
public class GWTWrapper implements PlatformWrapper {
public RestWrapper gwtRestWrapper;
public GWTWrapper(){
gwtRestWrapper = new GWTRestWrapper();
}
@Override
public RestWrapper getRestWrapper() {
return gwtRestWrapper;
}
GWTRestWrapper:
public class GWTRestWrapper implements RestWrapper {
public RestLogin restLogin;
public RestPortal restPortal;
public RestRegister restRegister;
public GWTRestWrapper(){
restLogin = new GWTRestLogin(); //GWTRest Logic
restRegister = new GWTRestRegister();
restPortal = new GWTRestPortal();
}
@Override
public RestLogin getRestLogin() {
return restLogin;
}
干杯。
工作变动:
public ApplicationListener getApplicationListener () {
setLoadingListener(new LoadingListener(){
@Override
public void beforeSetup() {
// TODO Auto-generated method stub
}
@Override
public void afterSetup() {
// TODO Auto-generated method stub
wrapper = new GWTWrapper();
client.setPlatform(wrapper);
}
});
return client;
我正在使用 Libgdx 编写 GWT 应用程序,在 运行 时加载正确的 rest 库时遇到一些困难。
在我的核心 gradle 项目中,我定义了一个 "RestWrapper" 接口,允许访问平台特定的 REST 功能(对于 GWT,RestyGWT)。当 HTML5 启动器是 运行 时,它将其实现传递给核心项目中的 LibGDX 游戏 class。
然而,当 HTML5 项目是 运行 时,编译的 JS 会引发此错误:
Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined
问题似乎出在第一个界面 (PlatformWrapper) 上。 我知道 GWT 编译器在接口方面有点笨拙,我是否应该采取不同的方法从我的核心项目中 运行ning GWT 特定代码?
调用代码(在核心项目中:)
UserSessionToken token =client.getPlatform().getRestWrapper().getRestLogin().attemptLogin(userNameBox.getText(),passwordBox.getText());
接口(在核心项目中):
PlaformWrapper
public interface PlatformWrapper {
public RestWrapper getRestWrapper();....
RestWrapper
/* Platform independent wrapper for REST services */
public interface RestWrapper {
public RestLogin getRestLogin();....
实施(在 HTML5 项目中):
PlatformWrapper(顶级)
public class GWTWrapper implements PlatformWrapper {
public RestWrapper gwtRestWrapper;
public GWTWrapper(){
gwtRestWrapper = new GWTRestWrapper();
}
@Override
public RestWrapper getRestWrapper() {
return gwtRestWrapper;
}
GWTRestWrapper:
public class GWTRestWrapper implements RestWrapper {
public RestLogin restLogin;
public RestPortal restPortal;
public RestRegister restRegister;
public GWTRestWrapper(){
restLogin = new GWTRestLogin(); //GWTRest Logic
restRegister = new GWTRestRegister();
restPortal = new GWTRestPortal();
}
@Override
public RestLogin getRestLogin() {
return restLogin;
}
干杯。
工作变动:
public ApplicationListener getApplicationListener () {
setLoadingListener(new LoadingListener(){
@Override
public void beforeSetup() {
// TODO Auto-generated method stub
}
@Override
public void afterSetup() {
// TODO Auto-generated method stub
wrapper = new GWTWrapper();
client.setPlatform(wrapper);
}
});
return client;