17

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

MountainRock
  • 594
  • 1
  • 9
  • 24

4 Answers4

16

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.

Leonel
  • 28,541
  • 26
  • 76
  • 103
  • Thanks Leonel for sharing. We are using Spring MVC and GWT +Smart GWT widgets with RestDatasource. Have chosen JSON request/response data format. So far so good. But initial impression is that the Smart GWT lacks standards and hard to customise. – MountainRock Mar 15 '11 at 23:31
2

Try this solution: GWT and Spring MVC Integration

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

alex.b
  • 1,448
  • 19
  • 23
1

It's stupid to mix Spring MVC and GWT. Also it's stupid to mix Spring MVC and JSF... It's stupid to mix 2 MVC (MVP) frameworks together. But you can use Spring DI and GWT for sure!

0

You may want to check out Spring Roo. It will help you get started quickly with Spring MVC, especially when dealing with RESTful URLs. It also provides a means to automatically set up GWT "scaffolding" (GWT code to interact with the Spring MVC backend). Hope it helps!

Andrew Wynham
  • 2,310
  • 21
  • 25