Flow
- Communication object is simple JS Array.
- GWT client layer is invoked by native JS call with array object created by External client application.
- JNSI Object get modified by server (using GWT Async. RPC call).
- Additional external app info’s can also be passed from external app(If required).
Benefits
- Call and communication object is same for all Actions like save, update, any other future operations.
- Hiding the details of internal integration part with GWT.
- Reducing number of native JS object creation.
JavaScript variable:
var arr= new Array()["one","two","three"];
JNSI Call :
private native JSHolderArray getArr()/*-{
return $wnd.arr ;
}-*/;
External JavaScript Object (arr)can be convertible to custom GWT JavaScriptObject to manipulate external script object using GWT JNSI call.
package com.google.gwt.sample.contacts.client;
import com.google.gwt.core.client.JavaScriptObject;
/**
*External javascript array object holder.
*
* @author Hiren
*
*/
public class JSHolderArray extends JavaScriptObject {
protected JSHolderArray() {
}
public final native int length() /*-{
return this.length;
}-*/;
public final native String getOtherData(int index) /*-{
return this[index];
}-*/;
public final native void setOtherData(int index, String data) /*-{
this[index] = data;
}-*/;
}