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:
- It's forwarded to the DispatcherServlet
- Then to an @Controller annotated bean.
- The processing is then handled by @Service bean.
- Afterwards, the controller returns a ModelAndView.
In a DWR-AJAX application, when a user submits a form, here's what happens:
- It's forwarded to the DispatcherServlet still
- Then to a @RemoteProxy annotated bean. The processing is handled by this bean. That's DWR's service bean.
- Afterwards, this remote proxy bean returns either an @DataTransferObject POJO or just plain HTML string
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.