ChrisK,

For instance method, you need to reference the method from the
instance like "th...@...". Here is my exact code that compile:

private native void installListener()
/*-{
    var callback = $entry(this.
@net.antidot.gwtcommon.mvp.share.client.channel.HTML5MessageChannel::process(Lnet/
antidot/gwtcommon/mvp/share/client/channel/HTML5MessageEvent;));
    $wnd.addEventListener("message", (function(callback, channel) {
        return function(event) {
            callback.call(channel, event);
        };
    })(callback, this), false);;
}-*/;

Sorry, I forgot that...

Olivier

On 23 mar, 13:58, ChrisK <[email protected]> wrote:
> Actually, Olivier's methods work in development mode but don't seem to
> compile with this error:
>
> "Cannot make an unqualified reference to the instance method callback"
>
> I've tried the pre-assignment of "this" to "var that" and also an
> argument to the JSNI method passing in my instance. I've tried both of
> these with Olivier's first method as well as the second to avoid
> leaks. All with the same result - working in development mode but not
> when I compile.
>
> It looks to me as though the compiler doesn't understand the call
> method or the closure correctly. It looks at though it's trying to
> parse the @mypackage.MyClass::MyMethod() and seeing it's an instance
> method so failed (instead of looking at subsequent JavaScript). Of
> course I could quite easily be doing something wrong.
>
> Thomas - your method compiles fine so I guess I'll use that for now.
>
> On Mar 23, 10:07 am, ChrisK <[email protected]> wrote:
>
> > Ahhh ok. Sorry for the simple questions but I'm just getting my head
> > around all this. I also have some other methods with arguments and
> > have those working thanks to both of you.
>
> > On Mar 23, 9:56 am, Olivier Monaco <[email protected]> wrote:
>
> > > ChrisK,
>
> > > On 23 mar, 10:32, ChrisK <[email protected]> wrote:
>
> > > > Thomas - your solution worked from 6 worked but at first I didn't
> > > > include both pairs of brackets after the function call "MyMethod" but
> > > > it turns out they are required. With only one set (i.e. no arguments),
> > > > it just doesn't work. I thought that was legal but maybe not.
>
> > > Remember that "@mypackage.MyClass::MyMethod()" is a reference to the
> > > function, not a call. The parenthesis allow you to give the full
> > > signature of the method. Java allows two methods to have the same name
> > > but different parameters. GWT needs the "full" signature to find which
> > > method you want to reference, even is there is only one method with
> > > this name.
>
> > > The second parenthesis are to call the method. If you forgot then, you
> > > just obtain the function object and do nothing with it...
>
> > > Olivier
>
>

a...@a

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