0
votes

What I want is to call this code

public native void eventClickHandler( String id) /*-{
  $wnd.jQuery('#' + id).bind('jqplotDataClick',function(ev, seriesIndex, pointIndex, data) {
    [email protected]::onClick(Ljava/lang/String;Ljava/lang/String;)(seriesIndex, pointIndex);
  });
}-*/;

Here the onClick method is a normal java method and I'm using GWT and JSNI interface for this. Thanks in advance!..

1
its not working sorry I think I forgot to mention it. - Shamitha Silva
the use of this is somewhat risky, as it refers to the function owner. is the JSNI method a member of an overlay type? please enclose more context code, and some generated exceptions, if exist. - Eliran Malka

1 Answers

1
votes

Have you used jQuery before? this has particular meaning inside a function passed to jQuery. Even in JSNI, while it is in a Java file, it won't behave like a Java this, but like a JavaScript this.

Try this instead:

public native void eventClickHandler( String id) /*-{
  var origThis = this;
  $wnd.jQuery('#' + id).bind('jqplotDataClick',function(ev, seriesIndex, pointIndex, data) {
    [email protected]::onClick(Ljava/lang/String;Ljava/lang/String;)(seriesIndex, pointIndex);
  });
}-*/;