作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 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/
我是一名优秀的程序员,十分优秀!