Posted by Unknown on 9:40 PM
Labels:

JavaScript Overlay Layer used to talk with GWT application from External client application.In Overlay Types you can augment the Java type without disturbing the underlying JavaScript object. For example, you can have getters and setters in the Java class that don't exist on the underlying JavaScript object. At the same time, your Java class is providing this richer functionality without GWT having to modify the underlying JavaScript object instance or its prototype.


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).

- Same modified Object get passed to External client app.

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;
}-*/;
}


0 comments: