3

I've built an app that is using ExtJS that connects through Ajax requests to a Jersey RESTful service. All is working well in this app but now I want to port it to ExtGWT.

Since ExtGWT already has the RPC servlets to handle the client-server communication, where can Jersey fit in this scenario? Should I not use it anymore and instead connect from GWT's servlets directly to the service methods?

In case I'd like to use Jersey, is there any way to have same support for serialization / deserialization as with GWT's RPC? - I assume I shouldn't use GWT's RPC anymore in this scenario.

I'd prefer Jersey because it has REST-based implementation while GWT's RPC I guess doesn't. In future I also plan to access Jersey's RESTful services from Android/iOS apps and GWT's RPC wouldn't fit very well in this scenario.

Thanks!

Dan L.
  • 1,717
  • 1
  • 21
  • 41

4 Answers4

2

Please look into the RestyGWT project. It will make calling JAXRS JSON resources as easy as using GWT-RPC. Plus you can typically reuse the same request response DTOs from the server side on the client side.

Hiram Chirino
  • 4,103
  • 1
  • 22
  • 21
1

You can smoothly combine Jersey (serverside) with RestyGWT (clientside). See http://blog.javaforge.net/post/30469901979/gwt-rest for further details.

mk_
  • 131
  • 1
1

You are correct that you can't use GWT RPC with REST. AFAIK, ExtGWT (GXT) doesn't have built in support for retrieving REST data; I could be wrong though, as I haven't used GXT in over a year.

As for using GWT RPC, it's very convenient to be able to reuse your models on both the server and the client. However, your models can't be too complex (they'll need to be able to be serialized to JSON); otherwise you'll need to create separate DTOs for your models. You can read more at the GWT RPC documentation: GWT RPC.

If it were me, I'd use both REST and GWT RPC. I'd use GWT RPC for communication with my client GWT code and Jersey/REST for communication with external apps.

JP Richardson
  • 38,609
  • 36
  • 119
  • 151
  • Thank you! I was also thinking about the option to use them both. On the other hand, I've just found some libraries(see next comment) that say provide REST support for GWT but I'm not sure how stable they are nor how easy is to work with them. They don't say anything about Jersey though so I don't know how the integration could be handled or if is possible. – Dan L. Jan 17 '11 at 13:37
  • 1
    http://restygwt.fusesource.org/documentation/index.html and http://code.google.com/p/gwt-rest/ – Dan L. Jan 17 '11 at 13:38
  • So I guess even if GWT RPC is not REST-based(which is a wide-spread standard that I'd love to use from GWT), it is still Google's standard which I guess is stable(no bugs, etc) and easy to work with to serialize/deserialize any kind of java beans. Compared to just-launched products like RestyGWT, I take GWT RPC is much solid and a more future-proof alternative. What do you think? – Dan L. Jan 17 '11 at 14:01
  • Regarding restygwt, I haven't used it so I can't comment on it. GWT-Rest looks dead though. As far as GWT-RPC being future-proof, in the technology world, I'm not sure that anything can be said to be future-proof. However, as of now, it's simple to use and is supported by Google. So I'd guess it'll be around for awhile. You also have the option of using RequestFactory. http://code.google.com/webtoolkit/doc/latest/DevGuideRequestFactory.html However, RequestFactory encourages writing a lot of code. e.g. DTOs and models. – JP Richardson Jan 17 '11 at 15:17
  • Thank you for searching a solution on my issue, I appreciate it - I'll try restygwt maybe something good comes up from it. – Dan L. Jan 17 '11 at 16:24
1

We have written an application (gradebook) that uses client side GWT/GXT and communicates via JAX-RS (Jersey) on the server side:

https://source.sakaiproject.org/contrib/gradebook2/trunk/

Initially we used GWT-RPC but than opted to use REST/JSON. Both communication patterns have their PROS/CONS. There is some information about both of them here: code.google.com/webtoolkit/doc/latest/tutorial/clientserver.html

tamsler
  • 1,275
  • 1
  • 18
  • 26