Thanks. Is there a tutorial on JavaScriptObject and JsArray somewhere
that you know of? I have already read the jsni chapter in "GWT in
Action" but still have trouble to understand how wrap  java objects
and java collections.

In my particular case I have 3 methods (below). I guess that there is
no magic involved so that changing return type of getMapJs() to
JsArray<JavaScriptObject> would not work.

On the other hand, I tried printing out the return value of
$wnd.__getMapJs() and that turns to be a huge JavaScript Object and I
have no idea how to iterate through it. So an example will help
tremendously.


        public Map<Long, GwtStock> getMap() {
                return stockMap;
        }

        public native Map<Long, GwtStock> getMapJs() /*-{
                return $wnd.__getMapJs();
        }-*/;

        public native void setUpJavaScriptApis(MapTest x) /*-{
                $wnd.__getMapJs = function() {
                        return [email protected]::getMap()();
                };
        }-*/;


On 16 Feb., 02:54, Shawn Brown <[email protected]> wrote:
>  Hi,
>
> > I am struggling with return types in methods implementing native
> > javascript interfaces. Returning strings is no problem, but calling a
> > method that returns a map
>
> >        public native Map<Long, GwtStock> getMap() /*-{
> >                return $wnd.parent.__getMap();
> >        }-*/;
>
> > works only in hosted mode (!) and either throws a classcast exception
> > or returns null.
>
> I don't know how to return a Map directly but you could try to return
> a JavaScriptObject
>
> seehttp://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/g...
> seehttp://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=goog...
>
> or what about:
>
> JavaScript Overlay Types
>
> Suppose you're happily using JSNI to call bits of handwritten
> JavaScript from within your GWT module. It works well, but JSNI only
> works at the level of individual methods. Some integration scenarios
> require you to more deeply intertwine JavaScript and Java objects --
> DOM and JSON programming are two good examples -- and so what we
> really want is a way to interact directly with JavaScript objects from
> our Java source code. In other words, we want JavaScript objects that
> look like Java objects when we're coding.
>
> GWT 1.5 introduces JavaScript overlay types to make it easy to
> integrate entire families of JavaScript objects into your GWT project.
>
> seehttp://code.google.com/docreader/#p=google-web-toolkit-doc-1-5&s=goog...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to