I have a web application that integrates DWR 3 and Spring 3. All requests are handled by the Spring's DispatcherServlet. Everything works. When I request an AJAX request, it's handled correctly by the backing DWR service bean annotated with @RemoteProxy. To return a response, my DWR service bean returns either an HTML string including the @DataTransferObject POJO or just the plain POJO.
What I want to do is in the DWR service bean I want it to forward the processing to a Spring @Controller bean. The AJAX request will still be processed by the DWR service but the real processing is delegated to the Spring controller bean. In other words the DWR service bean is just a service facade to the actual service. In this way I'm not duplicating logic.
Is this possible?
Let me clarify further.
In a normal non-AJAX application, when a user submits a form, here's what happens:
In a DWR-AJAX application, when a user submits a form, here's what happens:
Basically for the AJAX application, after step 2, I want it to forward to the @Controller bean so that everything is still processed by Spring.
Short answer is no.
There is no place in a DWR request for a spring controller. DWR has great support for remoting spring beans, but there is little value that a controller could bring to this equation.
That said there is no reason that I can think of that a spring 3.0 style annotated controller couldn't be used as the exposed DWR bean. The restriction would be that the return type would not be ModelAndView
rather it would just be your model object it's self.