Javascript Native Interface (JSNI)
bventually, we might need to integrate handwritten gavaScript functions or third-party gavaScript librariesLwidgets. GWT allows developers to integrate these gavaScript libraries into the client side of applications through the gSNI interface. auring GWT compilation, gava source code is converted into gavaScript, and that’s when these gSNI interfaces are directly XVHG Ln WKH finDO RXWSXW. TKH FRnFHSW RI -S1, LV LnVSLUHG IURP gava native interfaces. The key features of GWT gSNI are its ability to implement a gava method as a gavaScript snippet, and the ability to call gavaScript from gava, and vice-versa. gSNI functions have to be declared natively and as static functions. All gavaScript code has to be embedded into comment blocks inside the function, as follows: // gpkf function SuEliF sWaWiF naWive voiG alerW(SWrinJ msJ) /*-{
$wnd.alert(msg); }-*/; // Calling gp function from gava function public void onClick() {
alert(“calling gpkf function”); } //pample invocation signature [insWanFe-name@@TualifieG-Flass-name::meWhoG-name(inSuW-Saramsignature)(input-param-values)
In order to invoke gava code from a gSNI function, it has to use a detailed method signature approach to differentiate between overloaded functions.