gpt4 book ai didi

java - GWT 接口(interface)问题 : Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined

转载 作者:行者123 更新时间:2023-11-30 07:38:04 26 4
gpt4 key购买 nike

我正在使用 Libgdx 编写 GWT 应用程序,并且在运行时加载正确的其余库时遇到一些困难。

在我的核心 gradle 项目中,我定义了一个“RestWrapper”接口(interface),该接口(interface)授予对平台特定 REST 函数的访问权限(在 GWT 的情况下为 RestyGWT)。当 HTML5 启动器运行时,它将其实现传递给核心项目中的 LibGDX 游戏类。

但是,当 HTML5 项目运行时,编译的 JS 会引发此错误:

Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined

问题似乎出在第一个界面 (PlatformWrapper)。我知道 GWT 编译器在接口(interface)方面有点笨拙,我是否应该采取不同的方法来运行我的核心项目中的 GWT 特定代码?

调用代码(在核心项目中:)

UserSessionToken token =client.getPlatform().getRestWrapper().getRestLogin().attemptLogin(userNameBox.getText(),passwordBox.getText());

接口(interface)(在核心项目中):

平台包装器

public interface PlatformWrapper {

public RestWrapper getRestWrapper();....

休息包装

/* 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;

关于java - GWT 接口(interface)问题 : Breaking on exception: TypeError: Cannot read property 'getRestWrapper' of undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35083125/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com