Announcement Announcement Module
Collapse
No announcement yet.
How do I redirect from setSuccessView() to a Controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How do I redirect from setSuccessView() to a Controller

    Hi guys,

    I use SimpleFormController for a page and after I receive the response I want to redirect to a diferent controller not view. I want to do this only on the server side through setSuccessView(). Can somebody guide me how should I configure my springapp-servlet.xml?

    I want to call from HomeController the bean named: "/sessionStatsStaticUsersList.do".

    Code:
        <!-- ========================= VIEW DEFINITIONS ========================= -->
        
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass"><value>org.springframework.web.servlet.view.JstlView</value></property>
            <property name="prefix"><value>/WEB-INF/jsp/</value></property>
            <property name="suffix"><value>.jsp</value></property>
        </bean>
            
    	<!-- ========================= DEFINITIONS OF PUBLIC CONTROLLERS ========================= -->
    
    	<bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    
    	<bean name="/home.do" class="web.controller.HomeController">
    	</bean>
    	
    	<bean name="/sessionStatsStaticUsersList.do" class="web.controller.SessionStatsStaticController">
    		<property name="incomingPage" value="allUsersList"/>
    		<property name="server" value="Local"/>
    	</bean>
    Thanks and regards,
    Last edited by bogdanb; May 10th, 2007, 02:42 AM.

  • #2
    Re : How do I redirect from setSuccessView() to a Controller

    In springapp-servlet.xml
    in definition of HomeController,
    U can define as
    <property name="successview" value="/sessionStatsStaticUsersList.do"/>
    This successview is nothing but setSuccessView().
    It will redirect to another controller as u defined in xml..........


    Regards,
    Murugan.C

    Comment


    • #3
      Hi,

      Thanks for reply. I have tried like that, putting directly in the HomeController setSuccessView the bean name. The problem is that my bean does not extend the org.springframework.web.servlet.view.AbstarctView but the Controller, so I get exception when it tries to forward.

      So that's why I put the question because I need a mceanism (not especialy setSuccessView) to direct me on the ServerSide to another controller with all the model available from the coming page.

      Thanks and regards,

      Comment


      • #4
        I'm reasonably new to this but have you tried using AbstractWizardFormController if what you are trying to achieve is a wizard style form? There is a small tutorial on how to use it in the Manning book (Spring in Action).

        Comment


        • #5
          You can use "redirect:controllername.htm" as your view name as:

          <property name="successView" value="redirect:sessionStatsStaticUsersList.do" />

          Comment


          • #6
            Re : successView

            <property name="successView" value="redirect:sessionStatsStaticUsersList.do" />

            By adding "redirect" it will work...

            u can also try this other way in your Controller class

            return new ModelAndView(new RedirectView("sessionStatsStaticUsersList.do"));

            Note : But u should use either one only, not using the "redirect:" in xml and new RedirectView() in controller at same time.

            Comment


            • #7
              Hi,

              Were you able to send a model to the RedirectView?

              Anu

              Comment


              • #8
                Its not possible....since u r implementing new RedirectView...

                Comment


                • #9
                  u cannot access the model object from one controller to another controller since u r used redirectView

                  Comment

                  Working...
                  X