gwt-interop-utils shows one way of doing it. This assumes you are OK using intermediate collection types.
https://github.com/GWTReact/gwt-interop-utils/blob/master/DOCUMENTATION.md On Saturday, November 18, 2017 at 3:52:09 AM UTC-5, Chris L wrote: > > I'm trying to create a shared model in my GWT 2.8.2 application that I can > use both at the server and in GWT client code. > > My research/Google Fu tells me that this might be possible with JsInterop > but since I'm new to JsInterop I'm just not sure. > I've done some experiments but I've run into a couple of issues with the > biggest being that I can't have my model accessor methods if I make the > model native. The compiler tells me that they have to be native or > abstract. > > What I'd like to do with my model is: > @JsType > public class User { > private double id; > private String code; > private String name; > > @JsConstructor > public User() { > } > > @JsIgnore > public User(double id, String code, String name) { > this(); > > this.id = id; > this.code = code; > this.name = name; > } > > ... > @JsProperty > public double getId() { > return id; > } > > @JsProperty > public double setId(double id) { > this.id = id; > } > ... > } > > Then in my GWT application I'd like to do this: > > public class JsTypes { > > public static native <T> T getJsTypeObject(JavaScriptObject > result)/*-{ > return result; > }-*/; > } > > //called after REST response from server > private void onCallback(String json) { > Console.log("JSON:" + json); > JavaScriptObject result = JsonUtils.safeEval(json); > User user = JsTypes.getJsTypeObject(result); > ... > //do something with user > } > > Any ideas or suggestions would be greatly appreciated. > -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/google-web-toolkit. For more options, visit https://groups.google.com/d/optout.
