Announcement Announcement Module
Collapse
No announcement yet.
How to complete request manually without returning to DispatcherServlet.doDispatch() Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to complete request manually without returning to DispatcherServlet.doDispatch()

    Hi All,
    I'm trying to add the ability to invoke modal dialogs from a controller method. From something as simple as an Are You Sure? popup, to more complex questions.

    I want to provide a utility method that can be called from a controller method:
    public boolean askYesOrNoQuestion(dialogId, form, request, response) that behaves two ways:
    1. If the dialog question has been answered by the user, return the answer back to the controller.
    2. If the dialog has not yet been answered by the user, complete the http response back to the client without returning logic flow back to the calling controller method. Displaying the dialog in a lightbox.

    Completing the response manually from the controller is where it gets tricky.
    I can’t just do response.redirect() because I won’t get the view built up properly.
    I think I found a way using the “viewResolver” bean. It has a method .resolveViewByName() that should build me a spring.web View. I can then call view.render() and presto! <- hopefully

    My problem is I can’t get a reference to the “viewResolver” bean in my controller code. I think it's because they are defined in different contexts (defined in web context) And my controller is defined in the app context.

    Is there a way to merge the spring contexts to get access to viewResolver from a controller method??? I’m quickly stepping into the deep end of the pool.

    Also, any advice / experiences on how to complete the request manually would be great.

    Thanks
Working...
X