java.util.Map with Javascript Overlay example?

270 views
Skip to first unread message

rhodebump

unread,
Jun 18, 2010, 3:13:16 PM6/18/10
to Google Web Toolkit
Can anyone point me to an example in which someone uses Javascript
Overlays to create a java.util.Map. I've tried, but keep getting a

java.lang.ClassCastException:
com.google.gwt.core.client.JavaScriptObject$ cannot be cast to
java.util.Map


Is it even possible? Or am I limited to using a JsArray?

Thanks!

André Moraes

unread,
Jun 18, 2010, 3:18:51 PM6/18/10
to Google Web Toolkit
In JavaScript world, almost everything is a Dictionary.

If you simply need a dictionary, just use a JavaScriptObject.
Here is a example:

public final native void setValue(String key, String value) /*-{
this[key] = value;
}-*/;

private native static JavaScriptObject _createInstance() /*-{
var obj = new Object
return obj
}-*/;

I think the _createInstance isn't required, but I don't tested.

Dean S. Jones

unread,
Jun 19, 2010, 9:22:39 AM6/19/10
to Google Web Toolkit
Reply all
Reply to author
Forward
0 new messages