Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';在通过GWT-RPC传递给服务器的ArrayList中找不到对象_Java_Google App Engine_Gwt_Collections_Gwt Rpc - Fatal编程技术网

Java Can';在通过GWT-RPC传递给服务器的ArrayList中找不到对象

Java Can';在通过GWT-RPC传递给服务器的ArrayList中找不到对象,java,google-app-engine,gwt,collections,gwt-rpc,Java,Google App Engine,Gwt,Collections,Gwt Rpc,我有一个shortcutvirtualsystem的ArrayList,其中: public class ShortcutVirtualSystemEntry extends VirtualSystemEntry implements IsSerializable { public ShortcutVirtualSystemEntry(String id, String label, String image, String tooltip, String parent, in

我有一个
shortcutvirtualsystem
ArrayList
,其中:

public class ShortcutVirtualSystemEntry extends VirtualSystemEntry implements IsSerializable {

  public ShortcutVirtualSystemEntry(String id, String label, String image,
      String tooltip, String parent, int x, int y, int tray, Command action) {
    super(id, label, image, tooltip, parent, x, y, tray, action);
  }

public ShortcutVirtualSystemEntry() {

}

}
当我试图通过
RPC
调用将
ArrayList
从客户端传递到服务器时,列表中的所有对象都被实例化,但没有数据 以下是RPC:

docService.saveDocument2(shortcuts,
                new AsyncCallback<Void>() {

                    @Override
                    public void onFailure(Throwable caught) {
                        Window.alert("Faliled");
                        caught.printStackTrace();
                    }

                    @Override
                    public void onSuccess(Void result) {
                        Window.alert("Success");

                    }
                });
docService.saveDocument2(快捷方式、,
新的AsyncCallback(){
@凌驾
失败时的公共无效(可丢弃){
窗口警报(“故障”);
已捕获。printStackTrace();
}
@凌驾
成功时公开作废(作废结果){
窗口警报(“成功”);
}
});
服务器端:

@Override
public void saveDocument2(
        List<ShortcutVirtualSystemEntry> shortcuts) {
    for(ShortcutVirtualSystemEntry v: shortcuts)
    {
        System.out.println("Image "+v.getImage());// Prints : Image null...
    }


}
@覆盖
公共文件2(
列出快捷方式){
对于(ShortcutVirtualSystemEntry v:快捷方式)
{
System.out.println(“Image”+v.getImage());//Prints:Image null。。。
}
}
那么为什么我必须丢失我的列表数据呢?我做错了什么


非常感谢:)

我对GWT了解不多。但是RPC的一般规则是确保集合中的元素也是可序列化的。因此,如果您正在发送可序列化的列表,但列表中的对象不可序列化,则无法通过RPC正确获取元素。因此,请确保列表中的对象是可序列化的。

正如我所说,您的代码应该可以工作。可能您的问题在其他地方,例如,您忘记在构造函数中设置映像,或者您只是没有设置映像

GWT最重要的是,您通过RPC发送的对象是可序列化的,并且通常它也有助于为这些对象创建空构造函数


Sarajog

虽然我知道这些信息,但由于我的愚蠢,我忘了发出
命令
,这是
ShortcutVirtualSystemEntry
Serializable的字段,它位于您的代码Aysnc调用返回对象列表中