Skip to main content

Posts

Showing posts from January, 2009

Thoughts on GWT & Spring

I recently got involved in a project that used GWT and Spring. One of the first things that struck me was the lack of support for Dependency injection frameworks in GWT. So we had to come up with a Spring controller that looked similar to this public class SpringAwareGWTService extends RemoteServiceServlet implements Controller { private ThreadLocal servletContext = new ThreadLocal (); public final ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) { servletContext.set(request.getSession().getServletContext()); doPost(request, response); servletContext.set(null); return null; } public ServletContext getServletContext() { return servletContext.get(); } } Here, what we have done is create a spring controller that is also a GWT remote servlet. Only thing to note is that the GWT remote servlet was never intented to serve as a controller. Also we will force spring to accept the response provided b