Example usage for com.google.gwt.core.client JsonUtils safeEval

List of usage examples for com.google.gwt.core.client JsonUtils safeEval

Introduction

In this page you can find the example usage for com.google.gwt.core.client JsonUtils safeEval.

Prototype

public static native <T extends JavaScriptObject> T safeEval(String json) ;

Source Link

Document

Evaluates a JSON expression safely.

Usage

From source file:it.appify.geolocation.GeolocationJsObject.java

License:Open Source License

public void getCurrentPosition(GeolocationCallback callback) {
    ConsoleLogger.getConsoleLogger().log("getCurrentPosition .. " + callback);
    // if (this.callback != null && lastPosition !=null) {
    // // libero la callback pendente con l'ultime posizione e registro la
    // nuova//from  ww w. j  a  v a2 s . c o  m
    // callback.onPosition(lastPosition);
    // }
    this.callback = callback;

    JavaScriptObject geoOpt = JsonUtils.safeEval("{}");
    if (this.options != null) {
        String json = optionsMapper.write(this.options);
        geoOpt = JsonUtils.safeEval(json);
    }

    _getCurrentPosition(geoOpt);
}

From source file:it.appify.geolocation.GeolocationJsObject.java

License:Open Source License

public void watchPosition(GeolocationCallback callback) {
    ConsoleLogger.getConsoleLogger().log("watchPosition .. " + callback);
    this.callback = callback;
    JavaScriptObject geoOpt = null;/*from w  ww . j ava  2s  .  c o m*/
    if (this.options != null) {
        String json = optionsMapper.write(this.options);
        geoOpt = JsonUtils.safeEval(json);
    }
    if (watchId < 0) {
        watchId = _watchPosition(geoOpt);
    } else {
        // TODO: clear watch??? and renew subscription
    }
}

From source file:it.appify.geolocation.WsGeolocation.java

License:Open Source License

protected void connect() {
    webSocket = WebSocket.newWebSocketIfSupported();
    webSocket.setListener(new WebSocketListener() {

        @Override//from  ww w . j  a  v a 2  s .  com
        public void onOpen(WebSocket webSocket) {
            ConsoleLogger.getConsoleLogger().log("onOpen: " + webSocket.isConnected());
            if (currentRequest != null) {
                if (currentRequest.equals("watchPosition")) {
                    watchPosition(WsGeolocation.this.callback);
                    currentRequest = null;
                }
            }

        }

        @Override
        public void onMessage(WebSocket webSocket, ArrayBuffer data) {
            ConsoleLogger.getConsoleLogger().log("onMessage ArrayBuffer: " + data);

        }

        @Override
        public void onMessage(WebSocket webSocket, String data) {
            ConsoleLogger.getConsoleLogger().log("RECEIVED: " + data);
            JavaScriptObject jsonObj = JsonUtils.safeEval(data);
            onPositionSuccess(jsonObj);
            // parse string
        }

        @Override
        public void onError(WebSocket webSocket) {
            ConsoleLogger.getConsoleLogger().log("onError: ");
            // onPositionError(errorCode, msg);

        }

        @Override
        public void onClose(WebSocket webSocket, boolean wasClean, int code, String reason) {
            ConsoleLogger.getConsoleLogger().log("onClose: " + wasClean + " - " + code + " - " + reason);

        }
    });
    webSocket.connect("ws://127.0.0.1:8080//websocket");
}

From source file:it.appify.view.VueJsViewModel.java

License:Open Source License

@Override
public void bindModelToView(String viewId, M instance) {
    this.model = instance;
    String json = getObjectMapper().write(instance);
    JavaScriptObject jsObj = JsonUtils.safeEval(json);
    _create(viewId, jsObj);/*  w w  w . ja  v a2 s.  c o m*/
}

From source file:it.appify.view.VueJsViewModel.java

License:Open Source License

@Override
public void updateModel(M model) {
    ConsoleLogger.getConsoleLogger().log("1 updateModel: " + model.toString());
    String json = getObjectMapper().write(model);
    ConsoleLogger.getConsoleLogger().log("updateModel: " + json);
    JavaScriptObject jsObj = JsonUtils.safeEval(json);
    _updateModel(jsObj);//from w  w w.j  a  v a 2s .  com
}

From source file:next.celebs.api.JsonArrayReader.java

License:Apache License

@Override
public void onSuccess(Response response) {
    String txt = response.getText();
    Window.alert("1 succss '" + txt + "'");
    String escapedJSON = JsonUtils.escapeJsonForEval(txt);
    Window.alert("2 succss '" + escapedJSON + "'");
    JsArray<J> j = JsonUtils.safeEval(escapedJSON);
    Window.alert("3 succss '" + j + "'");
    ArrayList<T> msgs = JsUtils.toArray(j);
    Window.alert("4 msgs '" + msgs + "'");
    read(msgs, escapedJSON);//  www.  j  a va  2 s  . c om
}

From source file:next.celebs.api.JsonArrayStringReader.java

License:Apache License

@Override
public void onSuccess(Response response) {
    String txt = response.getText();
    String escapedJSON = JsonUtils.escapeJsonForEval(txt);
    JsArrayString j = JsonUtils.safeEval(escapedJSON);
    ArrayList<String> msgs = JsUtils.toListString(j);
    read(msgs);/*  w  ww.j a  v a2  s  .  com*/
}

From source file:next.celebs.JsoUtils.java

License:Apache License

@SuppressWarnings("unchecked")
public static <J extends JavaScriptObject> J toJSO(String json) {
    String escapedJSON = JsonUtils.escapeJsonForEval(json);
    JavaScriptObject j = JsonUtils.safeEval(escapedJSON);
    return (J) j;
}

From source file:next.celebs.JsoUtils.java

License:Apache License

public static <J extends JavaScriptObject> JsArray<J> toJSOArray(String json) {
    String escapedJSON = JsonUtils.escapeJsonForEval(json);
    JsArray<J> j = JsonUtils.safeEval(escapedJSON);
    return j;//from   w  ww.  j  ava2 s. c om
}

From source file:org.bonitasoft.web.toolkit.client.data.model.OverlayFactory.java

License:Open Source License

public static OverlayImpl create(String json) {
    return JsonUtils.safeEval(json);
}