Here is my class:
------------------------------------------------------------------
public class AssetItem {
private String PathName;
private String FileName;
private int Type;
public String getpathname() {
return this.PathName;
}
public void setpathname(String pathname){
this.PathName = pathname;
Window.alert("setpathname");
}
public String getfilename() {
return this.FileName;
}
public void setfilename(String filename){
this.FileName = filename;
Window.alert("setfilename");
}
public int gettype() {
return this.Type;
}
public void settype(int type) {
Window.alert("settype");
this.Type = type;
}
------------------------------------------------------------------
and here is the json input:
String json = "{\"pathname\":\"/var/www/imerge/user/assets\",\"filename
\":\"dailymail.jpg\",\"type\":1}";
If I take out the 'type' field from the json, everything works okay.
If I leave it in, the filename and pathname setters are invoked (they
trigger the window.alert dialogs) but the type one isn't. No matter
what datatype I use for this field - double, int, long, whatever - it
drops an exception stating it was expecting a native long.
What am I doing wrong?
Thanks,
Sean
[ERROR] Uncaught exception escaped
com.google.gwt.dev.shell.HostedModeException:
invokeNativeLong(@org.juglar.gwt.jsonizer.client.base.Defaults::asPrimitiveLong(Lcom/
google/gwt/core/client/JavaScriptObject;)): JS value of type
JavaScript object, expected long
at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
481)
at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeHandle(ModuleSpace.java:
225)
at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeHandle(JavaScriptHost.java:
89)
at
org.juglar.gwt.jsonizer.client.base.BeanJsonizer.setProperties(BeanJsonizer.java:
69)
at
org.juglar.gwt.jsonizer.client.base.BeanJsonizer.asJavaObject(BeanJsonizer.java:
104)
at
org.juglar.gwt.jsonizer.client.JsonizerParser.parse(JsonizerParser.java:
48)
at com.mrgsystems.imerge.client.dashboard$1.onClick(dashboard.java:
89)
at
com.google.gwt.user.client.ui.ClickListenerCollection.fireClick(ClickListenerCollection.java:
36)
at com.google.gwt.user.client.ui.Label.onBrowserEvent(Label.java:109)
at com.google.gwt.user.client.DOM.dispatchEventImpl(DOM.java:1211)
I get the exact same error too. What I did to investigate it was
comment out all the long/int members of my class, and remove them from
the json response too. I found that I got the objects back no problem.
So it appears to be a bug with int/longs (I tried it with longs too).
So basically, if you want it to work at the moment, it seems that the
members in the class must be Strings !
Bruce
I've been having the same problems with doubles as well. One thing
i've noticed is that the errors only happen in hosted mode. If i
compile and launch it it will work with no problem
Hope is fixed soon.....