java - Hashmap is empty on GWT async callback -
server side, construct java.util.hashmap, populate values (key , value both string) , pass client via async callback. empty when gets client side.
i can replicate net new hashmap used in 1 place server side. java 6 , gwt 2.7
server side service:
public class service extends remoteserviceservlet implements iservice { public model buildmodel() { model model = new model(); model.additemtomymap("key", "value"); return model; } }
model:
public class model implements serializable { private map<string, string> mymap = new hashmap<string, string>(); public void additemtomymap(string key, string value) { if(key != null) { mymap.put(key, value); } } public map<string, string> getmymap() { return mymap; } }
async interface:
public interface iserviceasync { public void buildmodel(asynccallback<model> callback); { }
client side:
service.buildmodel(new asynccallback<model>() { public void onsuccess(model model) { logger.warning(model.getmymap().size()); } public void onfailure(throwable caught) { logger.warning("error!"); } }
problem solved. eclipse save actions making map final , preventing serialization. when removed final modifier (and prevented eclipse adding back), able see map's contents on client side.
Comments
Post a Comment