--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
> Of course, if your really want Product as a "real" bean, and a List<?>
> instead of a JsArray<?>, you can copy things around (see below); but
> really I believe overlay types are much more readable than anything
> using com.google.gwt.json.* classes.
I used to use overlay type heavily (returning JSON from a Spring
MVC/Jackson backend) and it worked quite well. Although I found it
quite limiting to be unable to model "real" class hierarchies (JSOs
must not be subclassed). I really do this a lot on the server side. I
also really like to use the enhanced for loop for Lists and just do a
new Foo() instead of some tedious Foo.create(). Last but not least I
don't have a "Generate getters/setters" in Eclipse for my JSOs :)
All this led me to write a Generator which inspects my models ("real"
beans) and emits JSON mapping code handling simple properties, object
graphs and collections. That way I can work with real beans and
collections of beans in my (business) code and do the mapping from/to
JSON in my service/DAO layer (still sending/retrieving JSON to/from my
backend).
Sebastian
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
Of course you are right -- I wasn't precise (and thus wrong :) What I
meant (and "hate" :) is that you're not allowed to override methods
and that there is a "one interface to one JSO" constraint (since GWT
2.0). I like to have my domain models implement something like
EntityModel (a custom interface declaring Integer getId() and String
getrLabel() for example). That way, I can really simple build/populate
things like ListBoxes etc. GWT 2.1's ProvidesKey et al. gives us
another (and more flexible) solution for these problems though.
> That's why I created JsCollections a while ago with a set of
> JsArrays.toArray() methods that copies the JsArray into an array in
> DevMode but just "casts" it in prod mode (i.e. no single overhead once
> compiled to JS).
I used to do something similar. For dates and date-times as well (as
these types are Strings in the JSON requests -- this works best for me
at least). But I must admit, I'm lazy and I just (would) prefer to not
think about these conversions and "just use" Lists, Dates etc. as I do
on the server side.
Did you do any comparison in size and performance for the JSO vs.
native beans approach?
Sebastian