Reputation: 5061
I have an ArrayList
of ShortcutVirtualSystemEntry
where :
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() {
}
}
When I try to pass the ArrayList
from client to server through RPC
call all objects are of the List are instantiated but have no data
here the 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");
}
});
Server side:
@Override
public void saveDocument2(
List<ShortcutVirtualSystemEntry> shortcuts) {
for(ShortcutVirtualSystemEntry v: shortcuts)
{
System.out.println("Image "+v.getImage());// Prints : Image null...
}
}
So why do I have to lose my list data ? what I'm doing wrong
Thanks so much in advance :)
Upvotes: 0
Views: 288
Reputation: 164
As much as I can say, your code should work. Probably your problem is somewhere else, i.e. you forgot to set the Image in the constructor or you just don't set an Image.
What's important by GWT is, that the objets you send through RPC are Serilizable and often it also helps to create an empty Constructer for these objects.
Sarajog
Upvotes: 0
Reputation: 68715
I don't know much about GWT. But the common rule of RPC is to make sure that elements in collection are also serializable. So if you are sending list which is serializable but the objects in the list are not serializable then you will not get the elements correctly through RPC. So make sure the objects in the lists are seriablizable.
Upvotes: 1