Questions tagged [jsni]

JSNI is a means to include raw JavaScript code in a GWT application written in Java. JSNI is the web equivalent of inline assembly code.

JSNI (JavaScript Native Interface) can be used to integrate GWT with an existing JavaScript library, or to access low-level browser functionality not exposed by the GWT class API's. JSNI allows you to integrate JavaScript directly into your application's Java source code.

A JSNI method is declared native and contains JavaScript code in a specially formatted comment block between the end of the parameter list and the trailing semicolon. JSNI methods are called just like any normal Java method, and can accept parameters, call methods on Java objects, and return values to the Java-side of the application.

class JavaScriptCalculator 
{
  public static native int add(int n, int m) 
  /*-{ return n + m; }-*/;

  public static void main(String[] args)
  {
    System.out.println(JavaScriptCalculator.add(4, 8));
  }
}

The names $wnd and $doc are used to access the browser's window and document objects from JSNI.

public static native void say(String message) 
/*-{ $wnd.alert(message); }-*/;
365 questions
0
votes
1 answer

Calling a method inside a javascript function using GWT jsni

What I want is to call this code public native void eventClickHandler( String id) /*-{ $wnd.jQuery('#' + id).bind('jqplotDataClick',function(ev, seriesIndex, pointIndex, data) { …
Juliyanage Silva
  • 2,529
  • 1
  • 21
  • 33
0
votes
2 answers

GWT:not able to call a javascript method which is in mymain.html class from my onmoduleload

I am trying to call my Javascript method from my java in GWT below is what i am doing public void onModuleLoad() { jsniAlert("test"); } private static final native void jsniAlert(String test) /*-{ $wnd.alert(test); …
user1226162
  • 1,972
  • 8
  • 27
  • 42
-1
votes
2 answers

Convert java object into json by using javascript native function in gwt

I want to convert my java object into json by using JSNI i.e javascript native method in GWT. I dont want to use any external jar like Gson, jackson. I have dove following code. public class JsonToJavaUsingJS implements EntryPoint { final…
Ajinkya
  • 111
  • 1
  • 3
  • 13
-1
votes
1 answer

GWT: gray areas in Google Maps v3

Google Maps API V3 Gray Areas Here, it says we need to call google.maps.event.trigger(map, 'resize') to prevent gray areas on map. Is there any other way in GWT? If not, how can I call it on GWT without JSNI?
lembas
  • 377
  • 1
  • 7
  • 21
-2
votes
1 answer

how the two event become workable simulatenously in javascript

I am having a Label and the popup panel and when the mousemove over the label the popup will show and when the mousemove out of the label the popup will hide. I have completed till this but when the popup is showing and the cursor move inside it the…
user
  • 1
  • 4
1 2 3
24
25