我有一个场景,需要指定Synchrnous函数的返回类型,代码如下:
@RemoteServiceRelativePath("show_box")
public interface ShowBoxCommandService extends RemoteService{
public ArrayList<String> showBox();
}该方法在服务器上的实现为:
public ArrayList<String> showBox() {
ArrayList<String> box = new ArrayList<String>();
Iterator<Box> boxes = BoxRegistry.getInstance().getBoxes();
while (boxes.hasNext()) {
box.add(boxes.next().toString());
}
return box;
}我尝试在客户端以以下格式定义回调变量,以便调用该方法
AsyncCallback<Void> callback = new AsyncCallback<Void>() {
public void onFailure(Throwable caught) {
// TODO: Do something with errors.
// console was not started properly
}
@Override
public void onSuccess(Void result) {
// TODO Auto-generated method stub
// dialog saying that the console is started succesfully
}
};使用aync接口代码更新:
public interface ShowBoxCommandServiceAsync {
void showBox(AsyncCallback<ArrayList<String>> callback);
}但这会导致异步方法中的方法定义发生变化。
任何想法或线索都会有帮助。
谢谢,Bhavya
附言:如果这是重复的话,很抱歉。
发布于 2011-08-31 15:18:01
哈?你的方法返回一个ArrayList,而你在你的调用中声明为空?
Change <Void> to <ArrayList<String>>https://stackoverflow.com/questions/7253703
复制相似问题