Re: Best Practice for JSON object recreation on client

2016-08-22 Thread Ignacio Baca Moreno-Torres
"domain object" vs "message payload"; Yes, this is the point. We came from RequestFactory which works quite good with "domain object" models, we use one model for each type, this model is the same in the server and the client, and all views use the same model. So, responding to the 'JSON

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Thomas Broyer
I think the crux is thinking in terms of messages (payloads) rather than "domain objects". This applies to DTOs vs domain objects too, with RPC or RequestFactory or whatever. -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To unsubscribe from

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
I mean java8 Streams (https://docs.oracle.com/javase/8/docs/api/java/util/stream/package-summary.html). And I said that is the same as Immutable+FluentIterable because you can use Stream.of(values[]). And IMO this makes more sense in a DTO than using the interfaces on the collection

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
Thanks for the write up. I would definitely have it in mind. BTW can you expand a bit on the stream thingy? Is there a link somewhere to read about? Vassilis On Fri, Aug 19, 2016 at 8:59 PM, Ignacio Baca Moreno-Torres < igna...@bacamt.com> wrote: > Migrating everything is not a good idea,

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
Migrating everything is not a good idea, but you should give a try to arrays in new models or some parts of your application. We found that we frequently end up using Immutable collections and FluentIterable, and this is almost the same that using arrays and streams. As you said, migrating a

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
This makes sense for newer projects maybe. I already have a codebase and making trampolines to convert collections and maps to arrays and don't know what is a terrifying option. I prefer to depend on gwt-jackson (which doesn't work for me - resty-gwt works - resty-gwt is switching to gwt-jackson

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Ignacio Baca Moreno-Torres
IMHO supporting the whole collection frameworks is just an unnecessary complication. Just use plain array, not generics need, and now that stream are supported in GWT you has no excuse to use arrays. The inheritance is not solved in JsInterop for now, just try to avoid. On Friday, August 19,

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Vassilis Virvilis
How about transmitting nested Collections, Map, complex inheritance and generics? On Fri, Aug 19, 2016 at 4:30 PM, zakaria amine wrote: > I also tried to convert back to the original object: > > @JsType(isNative=true, namespace=GLOBAL) > public class JSON { > public

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
I also tried to convert back to the original object: @JsType(isNative=true, namespace=GLOBAL) public class JSON { public native static String stringify(Object obj); public native static Object parse(String obj); } and then: // Record converted = (Record) JSON.parse(json); and it works

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
It works. I prefer your solution. Le vendredi 19 août 2016 11:51:35 UTC+2, Jens a écrit : > > > > Am Freitag, 19. August 2016 11:43:12 UTC+2 schrieb zakaria amine: >> >> I have tried something like: >> >> @JsType(namespace=GLOBAL) >> public class Record { >> String id; >> String date; >> String

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Jens
Am Freitag, 19. August 2016 11:43:12 UTC+2 schrieb zakaria amine: > > I have tried something like: > > @JsType(namespace=GLOBAL) > public class Record { > String id; > String date; > String data; > public Record() { > } > } > By default @JsType property "isNative" is false, so your Record

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread zakaria amine
I have tried something like: @JsType(namespace=GLOBAL) public class Record { String id; String date; String data; public Record() { } } As mentioned above, I created a JsInterop wrapper for the JSON class in javascript : @JsType(isNative=true, namespace=GLOBAL) public class JSON { public

Re: Best Practice for JSON object recreation on client

2016-08-19 Thread Thomas Broyer
Or you could use an array instead of a collection. -- 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 google-web-toolkit+unsubscr...@googlegroups.com. To post to this

Best Practice for JSON object recreation on client

2016-08-18 Thread Luke Last
I use jackson/gson on the server to serialize and then gwt-jackson on the client to deserialize a shared pojo. I'm interested in finding out if JsInterop gives better performance though. -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Paul Stockley
I wrote a set of utilities using the new JsInterop capability in 2.8 that provides one way of handling JSON. Take a look at the documentation here https://github.com/GWTReact/gwt-interop-utils/blob/master/DOCUMENTATION.md We use Jackson on the server for handling the translation from JSON to

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Jens
> Why would it? You may want to use JsInterop to call JSON.parse() instead > of using JsonUtils and casts from JavaScriptObject, but I believe it'd just > work otherwise (can't try it ATM though) You can not use a Java Collection as field so you would need some conversion to JsArray that

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Vassilis Virvilis
Generally the GWT guys are careful and I am sure they will provide a way to migrate. If I understand correctly the mechanism that will replace generators (GWT.create()) is called APT and is based on annotations. In my codebase I don't have the need and so I don't really know but I am using

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Thomas Broyer
Why would it? You may want to use JsInterop to call JSON.parse() instead of using JsonUtils and casts from JavaScriptObject, but I believe it'd just work otherwise (can't try it ATM though) -- You received this message because you are subscribed to the Google Groups "GWT Users" group. To

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hi Thomas, wouldn't that still require MyObj to extend JavaScriptObject in order to be deserialized on the client? Thanks for your participation. Kind regards, max Am Donnerstag, 18. August 2016 10:41:28 UTC+2 schrieb Thomas Broyer: > > Have you tried something like: > >

Best Practice for JSON object recreation on client

2016-08-18 Thread Thomas Broyer
Have you tried something like: @JsType(isNative=true,namespace=GLOBAL,name="Object") class MyObj { String str; int num; } -- 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

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hello Vassilis, thanks for this contribution. This raises another question: is there a way to solve the above described tasks that is GWT 3 proof and already feasible in GWT 2.8? kind regards, max Am Donnerstag, 18. August 2016 09:45:08 UTC+2 schrieb Vassilis Virvilis: > > Hi, > > I am using

Re: Best Practice for JSON object recreation on client

2016-08-18 Thread Vassilis Virvilis
Hi, I am using resty-gwt. Resty-gwt had his own (forked from jackson I believe) json serialization classes. But now Rest-gwt is switching to gwt-jackson. I haven't managed to get gwt-jackson to work with my setup (yet) but looks like a valid path forward. In the server I am using CXF and the

Best Practice for JSON object recreation on client

2016-08-18 Thread Max Fromberger
Hello everybody, First of all a big THANKS to everyone involved in developing and supporting GWT. please correct me wherever I am wrong: In the past you used JsonUtils.safeEval() to create a JavaScriptObject from a JSON String. As i understand it, jsinterop annotations on classes not