- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有一个关于 GWT 的异常问题。在我的浏览器上编译项目后,我通过打开 .html 文件来运行它。它运行良好,直到出现以下代码行:
public static ClickHandler addBoardButtonHandler(final String name) {
return new ClickHandler(){
@Override
public void onClick(ClickEvent event) {
Window.alert("We will retrieve them!"); //this line runs
String boardSTickets = getBoardSTickets(name); // this too
Window.alert("We got tickets!"); // the code is never executing this line
String boardSSwimlanes = getBoardSSwimlanes(name);
Window.alert("We got swimlanes!");
KanbanizerClient.showSingleBoard(boardSTickets, boardSSwimlanes);
}
};
}
这个方法被另一个方法调用:
private static Button addBoardButton(String name) {
Button button = new Button(name);
button.addClickHandler(HandlerManager.addBoardButtonHandler(name));
return button;
}
这也正常运行。这是 getBoardSTickets() 方法:
protected static String getBoardSTickets(String name) {
final List<String> ticketsJSON = new LinkedList<String>();
try {
Request request = Builder.createBuilder(RequestBuilder.GET, "http://localhost:8080/Kanbanizer/boards/" + name + "/tickets").sendRequest(null, new RequestCallback(){
@Override
public void onResponseReceived(Request request,
Response response) {
if(response.getStatusCode() == 200){
ticketsJSON.add(response.getText());
}
}
@Override
public void onError(Request request, Throwable exception) {
// TODO Auto-generated method stub
}
});
} catch (RequestException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ticketsJSON.get(0);
}
谢谢你:)
最佳答案
要了解 GWT 上下文中的 ajax - 请通读 https://developers.google.com/web-toolkit/doc/latest/tutorial/clientserver 中的“进行异步调用”部分
您将 getBoardSTickets() 编程为在执行异步请求调用后返回字符串的方法是有缺陷的。不要尝试在 getBoardSTickets() 中返回异步调用的结果。
return ticketsJSON.get(0);
在 sendRequest()
之后立即被调用。它会抛出异常,因为 ticketsJSON 的条目为零,因为 RequestCallback() 不会完成处理。
尝试从外部传递一个回调
protected static String getBoardSTickets(String name, RequestCallback callback){
//Code for making request
}
您的调用代码应更改为
getBoardSTickets(name, new RequestCallback(){
//onSuccess and onFailure handling.
} )
同样的逻辑适用于调用异步调用服务器的所有方法。您不应编程为从该方法返回请求响应的值。
关于java - GWT 突然停止执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15600590/
无论我在做什么,我都会得到这个输出,但模拟器不会启动,新创建的模拟器也不会启动。我在 Windows 下: 警告:./android/base/files/IniFile.cpp:155:无法处理 .
我用 package.json NPM 脚本中像这样的变量: // package.json { "version": "0.12.1", "scripts": { "get-vers
几天前,Facebook 与我们网站的连接突然停止工作,代码没有任何更改??? Facebook 做了一些改变??? http://www.presbium.sk/vstup-pre-uchadzac
我习惯于 grunt build 任务成功完成,但由于我将我的项目编辑与其他开发人员同事合并,它突然失败并出现我以前从未见过的错误: grunt build Loading "imagemin.js"
我不明白这个。突然之间,我无法使用 iOS 9.0 中引入的 UIUserNotificationActionResponseTypedTextKey 标识符来访问通知中的文本输入消息。 Xcode
在我调用某个 Google 的 Youtube 库后,我的应用程序在其回调之一后突然变得完全没有响应。 无响应意味着无法点击所有 UI 组件。 在 iOS 中是否有这样的东西可以禁用整个屏幕完全不响应
bool queueIsFull(int rearPointer) { if(rearPointer==9) return 1; else return
我正在使用 PHP、Apache 和 MySQL 开发 Web 应用程序。在过去的一年中,此应用程序的响应时间一直不错。昨天,应用程序在 Firefox 上突然变得非常慢(完整的页面加载,包括 CSS
几个小时后,从控制台发出的 PHP 命令不再接受本地路径。例如在 laravel 中我总是给出命令 php artisan 但从今晚开始我收到了以下回复 Status: 404 Not Found C
我有一个 session WCF 服务,它生成一个进程并在调用 IsInitiating 操作时打开一个到该进程的命名管道。当调用 IsTerminating 操作时,服务会沿着管道发送一条消息,通知
类似的问题已经回答了好几次,我确实检查了其中的许多问题。这是不同的,请继续阅读。 我在 strings.xml 中定义了大量(大量)字符串,并带有多个格式参数。例如: %s and also %s 这
我有一个简单的消息机器人,它是根据 Messenger 平台指南设置的。在过去的几个月里,它一直运行良好,每天发送大约六条消息。我根本没有碰它,但是突然,发送消息,即调用 https://graph.
我正在使用 Unity 开发一款简单的 3D 手机游戏。我的目标是在没有垂直同步的情况下达到 30 FPS。我的游戏在所有 iOS 设备上运行良好,没有发热和节流,但有奇怪的 FPS 下降。 FPS
我们有一个自定义小部件,多年来一直运行良好,直到上周。 看来 Json 回调现在仅适用于播放列表,不适用于轨道。 播放列表 /**/jQuery31108094578850496614_1482167
-bash:/Users/winchenzo/git-completion.bash: 没有那个文件或目录 -bash:/Users/winchenzo/git-prompt.sh: 没有那个文件或目
编辑:重启解决了问题。我仍然想知道最初是什么原因造成的,因为这种情况以前发生过一次,但我不记得当时我做了什么来修复它(当时重新启动并没有解决问题)。 我 cd 到包含我要编辑的文件的文件夹,然后从命令
我刚刚注册是因为我突然遇到了一个问题,目前为止运行良好的代码我之前在这里找到了一些非常好的答案。希望你们能再次帮助我,这次甚至是投票;) $sql='SELECT projektKurz, proje
我制作了一个小程序,它在 tcp 套接字上监听和发送线路,并将接收到的信息附加到 JTextArea。我用它在 Minecraft 服务器上聊天,而无需打开游戏。 我昨晚工作得很好,但当我起床时却不工
感谢您在这里查看我的问题。 我正在使用 Glide 从 Firebase 存储中获取图像,基本上我是在使用 url 从存储中获取图像。第一天它工作正常但突然停止获取图像。我没有碰代码。我检查了很多答案
FCM 通知已到达所有 iOS 设备。但通知在大约 1 年前注册的某些设备上不起作用。 FCM token 和 APNs token 似乎没有变化。为什么没有到达通知? FCM token 是否必须过
我是一名优秀的程序员,十分优秀!