Results 1 to 7 of 7

Thread: Chaining controller

  1. #1
    Join Date
    Sep 2004
    Posts
    8

    Default Chaining controller

    I would like to know if it is possible after processing a Controller to redirect to another Controller.

    Example:
    After filling up a form and inserting the data in the database(InsertController) I want to show a list of all values(ListController)
    This are 2 different actions so should be in different Controllers, how can configure this in Spring MVC?

  2. #2
    Join Date
    Aug 2004
    Location
    Montréal, Canada
    Posts
    845

    Default

    One solution is to return a new RedirectView(url). This is very handy when user hits F5 (refresh the page). Only the last controller (ListController) will be invoked.
    Omar Irbouh

    Spring Modules Team
    http://irbouh.blogspot.com/

  3. #3
    Join Date
    Sep 2004
    Posts
    8

    Default

    That means that the chaining must be done when I return de ModelView.

    I cannot configure that in the bean declaration on the sucessView property of the SimpleFormController.

  4. #4
    Join Date
    Aug 2004
    Posts
    29

    Default

    If you are using the multiactioncontrollers, then you could do this by just invoking the correct method of the multiactioncontroller. Otherwise I dont know how it should be easy possible in the springframework, and this issue was one of the reasons I started http://www.competities.com/springworkflow so I could handle these situations easily. And I wanted to have all the navigation stuff in a separate file so I could easily remove links on certain pages.

    Basically, in a controller when you want to redirect, you throw a WorkflowRedirectException("workflowname.pageflowna me.pagename") and the springworkflow will go there. If you add a model to the exception, then the model will be available in the next controller as well. So for instance you could save in one controller, add a saved message to the model and then redirect to another controller, and the saved message will still be available.

    Regards
    Ronald

  5. #5
    Join Date
    Sep 2004
    Posts
    2

    Default redirect controller to controller with request object?

    hi
    redirectView only mak url redirection.
    if we use render method of redirectView and add request parameter to Map, we send request parameters to other controller, so other controller can take request parameter as follow
    String username=request.getParameter("username");
    but our controller need to use attributes of request for object values,

    User user = (User) request.getAttribute("user");

    in this case we sent request object controller to other controller
    how can I do?

  6. #6
    Join Date
    Oct 2009
    Posts
    16

    Default

    Were you able to resolve this?

  7. #7
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    Well, digging out a 6 years-old thread...everything has changed since then in the Spring world, with Spring 3.0 web mvc just return "forward:nextURL" in your controller's method after you have processed data from the first page. As simple as that...

Similar Threads

  1. View to forward to another controller?
    By justinp in forum Web
    Replies: 6
    Last Post: Apr 2nd, 2010, 01:53 PM
  2. Replies: 4
    Last Post: Dec 17th, 2008, 01:47 PM
  3. Replies: 6
    Last Post: Jul 20th, 2007, 05:56 AM
  4. Controller forwaring
    By ojs in forum Web
    Replies: 5
    Last Post: Jul 11th, 2005, 02:10 AM
  5. Controller chaining?
    By sburkard in forum Web
    Replies: 3
    Last Post: May 31st, 2005, 05:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •