One type for all

52 views
Skip to first unread message

Adolfo Panizo Touzon

unread,
Dec 10, 2011, 8:34:09 AM12/10/11
to google-we...@googlegroups.com
Hi,

The last two years I have worked with GWT and other technologies (REST, JPA, Validation (JSR 303 ....)). In all projects that I developed I found always a commom problem.

The compatibility of the data.

For example, If I use some annotatons in the Entity to allow the REST functions I can´t instantiate these Entity in the client side of GWT (problems with the compiling to JS), or I found problems to transport the object to the database in an automatic way, or if I use JSON to transport the data I must create extra class to manage the native information, or if i use a commom mechanism to transport it (RPC) the work becomes very heavy....

I don´t know if I have explained enough well, but, the question is, what do you do to avoid these problems??

There is a commom way that we can follow??

Any suggestion or comment are welcome.

Thank you so much.

Adolfo.  

--
El precio es lo que pagas. El valor es lo que recibes.
Warren Buffet

Thomas Broyer

unread,
Dec 10, 2011, 8:50:01 AM12/10/11
to google-we...@googlegroups.com
This is (partly) what RequestFactory tries to solve (vs. GWT-RPC): you no longer use your server-side classes on the client-side, so you don't have the issues of your entities having to be "translatable" by the GWT compiler.

If you work with JSON (using things like Jackson or GSON on the server-side), you can use AutoBeans on the client-side (you can also use them on the server-side, btw) to easily parse and manipulate the objects (at least a bit more easily than with JsonUtils.safeEval() and JS Overlay Types).

But if you only add annotations to your classes, there's no reason you couldn't use them on the client-side too; you just have to make sure you have the source code for the annotations on the classpath too.

Just a suggestion; AutoBean and RequestFactory are not a silver-bullet, and JSOs and GWT-RPC are still viable choices (FYI, Google Groups uses GWT-RPC).

Ed

unread,
Dec 11, 2011, 6:23:33 AM12/11/11
to Google Web Toolkit
I don't think there is a perfect solution currently.
It all depends on your situation.

The RequestFactory is nice if you have access to the backend, as this
mechanism requires a "further" integration between the backend and
frontend. But not everybody has access to this part of the backend but
merely "the web layer backend" on top of the backend that handles all
the front-end communication.
However RequestFactory is very efficient.

If you only want parts of the domain object (DO) to be transfered to
the front-end (like in my case), you need to create DTO and convert
DTO <-> DO which costs time to fine tune all and is fragile (make sure
you test it well). I use Dozer, but had to make my own dozer branch
due to bugs and extra requirements.

I understood that Java 7 would offer extra DTO functionality, no idea
what the current status of this is.

- Ed

Steve Moyer

unread,
Dec 11, 2011, 9:43:15 PM12/11/11
to Google Web Toolkit
"RequestFactory is nice if you have access to the backend"

I'm using AutoBeans (which were designed for RequestFactory) to
marshall and unmarshall my model classes on the client side without
having access to the server side. I don't have a JEE server or even a
servlet container as I'm using CouchDB. My models are interfaces
annotated as EJB3 POJOs but also annotated with validations. And I'm
exporting them from CouchDB to an RDBMS using Hibernate. So I have
models that are used for the client side, a NoSQL and an RDBMS.

Think it through ... you'll get there too!

smoyer

Adolfo Panizo Touzon

unread,
Dec 12, 2011, 4:23:17 AM12/12/11
to google-we...@googlegroups.com
Thank you so much for all the information it was very useful.

In the future we are going to migrate to RequestFactory with AutoBeans (it allowed all the types that we are using)

Really thanks.

Adolfo.

2011/12/12 Steve Moyer <smoy...@gmail.com>
--
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.

Reply all
Reply to author
Forward
0 new messages