0

Currently we have on the server side a spring mvc application. We need to change the client part and we checking GWT.

Is there a way from the gwt code to call a spring controller?

redfox26
  • 2,020
  • 4
  • 25
  • 33
  • 1
    Yes, a call to a REST service is just straight forward HTTP. so if you can construct a URL and send it with the appropriate headers, then you can call the service – Romski Feb 19 '14 at 23:00
  • 2
    http://stackoverflow.com/questions/4030969/how-to-call-restful-services-from-gwt – sodik Feb 20 '14 at 08:12
  • @sodik with theses solutions, there are some modification to do on the server, is not straightfoward. – redfox26 Feb 20 '14 at 21:46
  • If you have really rest service on the server side, it can be called by any client side code... wether it is gwt or not. And above question just answers how to call rest from gwt. If you have other problem, pls describe it. – sodik Feb 21 '14 at 22:27

1 Answers1

1

You can call your Spring controllers by submitting forms. This is the difference between the two architectures: GWT uses javascript on the client side to do the job, and communicates with the server only to grab the necessary data (and send the minimal data), Spring MVC requires an http request on each click, and rebuilds the whole page.

You can keep the Spring MVC logic of submitting a form with the data when the user finishes his job with the page (in GWT it's a module). And have GWT commodities to handle the UI in js until the job is finished (client side validation, interactive experience). You can submit a "traditional" form in GWT easily. Then your MVC logic will point the user to another "GWT module": (you can see this in action when you switch between Contacts and Mail in Gmail)

To have an idea on what can be done without the server interaction, take a look at this lib where I guarantee you everything is client side (since it's my lib :) ) here: https://code.google.com/p/advanced-suggest-select-box/

Zied Hamdi
  • 2,400
  • 1
  • 25
  • 40