Problems with numeric fields

5 views
Skip to first unread message

Sean Keeney

unread,
Jul 31, 2007, 11:35:35 AM7/31/07
to GWT Jsonizer
Hi, I've had this problem before but have just come back to revisit
it.

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

Sean Keeney

unread,
Jul 31, 2007, 11:43:23 AM7/31/07
to GWT Jsonizer
Sorry, I forgot to paste the exception report:

[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)

brucepercy

unread,
Sep 27, 2007, 7:15:21 AM9/27/07
to GWT Jsonizer
Hi Sean,

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

Nicolás N

unread,
Oct 30, 2007, 6:14:33 AM10/30/07
to GWT Jsonizer
Hi boys!!

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.....

eliasbalasis

unread,
Dec 28, 2007, 10:17:30 PM12/28/07
to GWT Jsonizer
Same problems here. But I managed to solve part of it.

When asPrimitiveLong is called the passed object is of type 'object'
and not 'number' as expected, so I used
'return parseint(jsValue);' instead of 'return jsValue;' and it
worked.
I suspect related errors may occur in related cases
(asPrimitiveDouble, asPrimitiveBoolean).
The fact that I am getting similar errors when playing with types
other than String and int is I believe directly related.
Can you please include the fix or a better one in your next release?
and check the remaining cases also?

Wishes for Happy new year
Reply all
Reply to author
Forward
0 new messages