OpenSource For You

Javascript Native Interface (JSNI)

-

bventually, we might need to integrate handwritte­n gavaScript functions or third-party gavaScript librariesL­widgets. GWT allows developers to integrate these gavaScript libraries into the client side of applicatio­ns through the gSNI interface. auring GWT compilatio­n, 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-Saramsigna­ture)(input-param-values)

In order to invoke gava code from a gSNI function, it has to use a detailed method signature approach to differenti­ate between overloaded functions.

Newspapers in English

Newspapers from India