Of course this also means that an instance created in JavaScript and
passed into Java is not an instance of com.mypackage.Foo... it's a
JavaScriptObject.


Good points, though.



On Jun 3, 10:24 am, "Dean S. Jones" <deansjo...@gmail.com> wrote:
> This is from memory, but in general, I thing it should work:
>
> package com.mypackage;
>
> public class Foo
> {
>     private String message;
>
>     public Foo(String message)
>     {
>         this.message = message;
>     }
>
>     public void sayHello()
>     {
>         Window.alert("Hello " + message);
>     }
>
>     public static native void export() /*-{
>
>         function Foo_Type(message)
>         {
>             this.instance = @com.mypackage.Foo::new(Ljava/lang/String;)
> (message);
>         }
>         Foo_Type.prototype.sayHello = function
> { this.instan...@com.mypackage.foo::sayHello()(); }
>
>         $wnd.Foo = Foo_Type;
>     }-*/;
>
> }
>
> Call Foo.export() from your onModuleLoad()
>
> JavaScript should then be able to do:
>
> var f = new Foo("Dean");
>
> f.sayHello();
>
> On Jun 3, 9:35 am, jarrod <jarrod.carl...@gmail.com> wrote:
>
> > I did check it out, but unfortunately, there seems to be a bug in the
> > framework preventing me from doing what I want.
>
> > I'm trying to follow up with that group on the issue, but the long and
> > short is that (trust me on this) I couldn't get it working with my
> > code.
>
> > However, after looking through the gwt-exporter source code a bit, I
> > am encouraged that this sort of thing is possible - I just can't crack
> > how to do it without the aid of a third-party library.
>
> > Thanks. Any other suggestions?
>
> > On Jun 2, 11:43 pm, "Dean S. Jones" <deansjo...@gmail.com> wrote:
>
> > > Short answer, check out:
>
> > >http://code.google.com/p/gwt-exporter/
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to Google-Web-Toolkit@googlegroups.com
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to