How to pass javascript object to GWT method and parse result

被刻印的时光 ゝ 提交于 2019-12-05 22:30:47

If I have correctly understood the question, I'd use an overlay type, something like:

public class ProductJso extends JavaScriptObject {
  protected ProductJso() {}
  public final native int getId() /*-{ 
    return this.id;
  }-*/;
  public final native int getCategoryId() /*-{
    return this.categoryid;
  }-*/;
  public final native String getName() /*-{
    return this.name;
  }-*/;
  // And so on...
}

Then modify you JSNI to return the actual JSO type

public static native ProductJso getJsValue() /*-{
  return $wnd.product; 
}-*/;

You get the idea, see also https://developers.google.com/web-toolkit/doc/latest/DevGuideCodingBasicsOverlay?hl=it#example-json

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!