Experiences with integrating spring 3 mvc with GWT?
Asked Answered
M

4

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

Mccready answered 18/2, 2011 at 11:19 Comment(0)
W
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.

Wei answered 3/3, 2011 at 13:13 Comment(1)
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.Mccready
E
2

Try this solution: GWT and Spring MVC Integration

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

Esculent answered 12/10, 2011 at 12:34 Comment(0)
F
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!

Fugere answered 24/4, 2014 at 9:55 Comment(0)
C
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!

Cele answered 10/3, 2011 at 23:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.