Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Experiences with integrating spring 3 mvc with GWT?

Given: Spring 3.0 mvc has excellent REST support with one of the representation being JSON.

GWT simplifies development as UI is developed in java. But by default it uses RPC for client server interaction. But there is an option to use JSON.

Questions:

  1. Can you share experiences with using Spring 3.0 mvc with GWT ?

  2. What is the best approach to integrate these two frameworks?

  3. Is the default GWT's MVP architecture only for client side and does it work well with JSON?

Thanks

like image 947
MountainRock Avatar asked Feb 18 '11 11:02

MountainRock


2 Answers

Can you share experiences with using Spring 3.0 mvc with GWT ?

Yes. We've successfully built a whole large application around GWT and Spring MVC (1500 source files, 6 months in development).

Spring was the key to the project's success. Only with Spring we were able to test individually some pieces of the application on the server side.

What is the best approach to marry these two frameworks?

Ignore the default Servlet used by GWT and instead create your own Spring controller to handle incoming GWT-RPC requests. This blog post was the key to integrating the two techs.

We also successfully integrated other components: Flash for animated charts and third-party Javascript components for other stuff. These communicate with the server through JSON. So you have two or more kinds of URLs:

  • the *.rpc urls are for GWT components and are served by the Spring controller for gwt
  • the *.json urls are for other components and are served by another Spring controller.

Also, in our case, we shunned configuration with annotations and instead preferred configuration with the good old Spring XML files. They make it much more clear what's going on. Except for the @Required annotation; it's great to find spring beans that should be connected but aren't.

Is the default GWT's MVP architecture only for client side and does it work well with JSON?

GWT's MVP architecture works best if you follow the guide lines. Use GWT-RPC communication as Google suggests.

You can still have JSON for other client-side components.

like image 79
Leonel Avatar answered Sep 30 '22 16:09

Leonel


Try this solution: GWT and Spring MVC Integration

It uses 3 classes. Its very simple, declarative and clear.

like image 32
alex.b Avatar answered Sep 30 '22 15:09

alex.b