我对 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);
}
谢谢 :)