Reputation: 53
What AJAX libraries work well with Spring MVC?
I'm new to developing with Spring and Spring MVC. From the documentation at http://www.springsource.org I'm not yet understanding what AJAX framework Spring MVC has built-in or what third party APIs and tooling might be suggested as working well with developing a Spring MVC application.
All recommendations are appreciated.
I did search through previous SO discussions on this subject, but I didn't get any clear direction.
Upvotes: 5
Views: 5022
Reputation: 1473
Here is another approach to let Spring MVC to work with ZK UI components - Rich Web Application with Spring MVC CRUD Demo
In that article, it used Spring MVC controller to communicate with ZK UI components. (all in Java code)
Upvotes: 2
Reputation: 66
Please go through the following link. It clearly explains how it needs to be done.
http://blog.springsource.org/2010/01/25/ajax-simplifications-in-spring-3-0/
Upvotes: 3
Reputation:
Spring doesn't deal with Javascript frameworks, per se. I don't know if Springsource does any advocacy for any particular Javascript framework or whether they are agnostic. Ajax is really just a technique enabled by browser technology in combination with the Javascript language and what matters is the ability to pass some kind of serialized data between client and server. It isn't that difficult to cook up your own basic AJAX framework and you could even design your own data encoding and not use JSON or XML. It is wise to adopt an existing framework and standards because you don't want to maintain a lot of ancillary code or worry about it, and instead focus on the problem you are trying to solve. So that is why there are many Javascript frameworks out there that can do asynchronous requests and some have some really nice features and capabilities that make your life easier, for example jQuery provides excellent DOM manipulation and browser-neutral functionality. I think that using Spring MVC in conjunction with the Jackson JSON library on the server side, and jQuery on the client side, is the basis for a very decent end-to-end solution. I have had a lot of success with jQuery and jQuery-UI, but other Javascript frameworks can work just as well. For complex applications, you basically end up needing what amounts to a second MVC on the client side because you need that breakdown between UI widgets and the data that has to move between client and server.
Upvotes: 1
Reputation: 1964
Spring JS has support of Dojo JavaScript framework. Spring Js
Upvotes: 1
Reputation: 26574
Spring is super easy to use with Ajax. If Jackson is on the classpath Spring can use it for returning JSON to the caller. Something like this:
@RequestMapping( "/my/path" )
public @ResponseBody MyObject doSomething( @RequestParam Long myVal ) {
MyObject result = new MyObject( myVal );
// do something interesting
return result;
}
Then you can use jQuery (or your other favorite javascript library) to make a request to http://myserver/my/path
and handle the resulting JSON object.
Google's GSON is also easy to use. As in:
@RequestMapping( "/my/path" )
public ResponseEntity<String> MyObject doSomething( @RequestParam Long myVal ) {
MyObject result = new MyObject( myVal );
// do something interesting
HttpHeaders headers = new HttpHeaders();
headers.set( "Content-Type", "application/json" );
String json = gson.toJson( result );
return new ResponseEntity<String>( json, headers, HttpStatus.CREATED );
}
Upvotes: 8