Announcement Announcement Module
No announcement yet.
Call from a Form to another Form Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Call from a Form to another Form

    Hi friends!!!

    I've to do a call from a SimpleFormController to another SimpleFormController, but I don't know how i can do it, because i want to call to the controller of the second form, not to the view.
    If i use:
    return new ModelandView("mysecondform","model",model);
    it will go directly to the view, giving me an exception, not passing around the "formBackingObject" method.

  • #2
    One way I have done this is to define a view (such as "success") as a forward or redirect (if you want to expose the second action's url to the client).
    Something like this in the app-servlet.xml will work...
     <bean id="adminNewProjectController" class="package.NewProjectController">
    	<property name="successView"><value>redirect&#58;admin_projects.html</value></property>
        <property name="formView"><value>admin_new_project</value></property>
    The action then simply returns the a MAV with name "successView" and the action is redirection to the action that is mapped to admin_projects.html.

    You can also use forward:name_of_action



    • #3
      Thanks dhainlin

      I've tried to do what you say. My ...-servlet.xml now is like that:

      <!--  Validador y Controlador del formulario para la edicion de Contactos" -->
          <bean id="contactoValidator" class="jsp.ContactoValidator"/>
          <bean id="editarContactoForm" class="opr.EditarContactoFormController">
              <property name="sessionForm"><value>true</value></property>
              <property name="commandName"><value>contacto</value></property>
              <property name="commandClass"><value>jsp.ContactoCommand</value></property>
              <property name="validator"><ref bean="contactoValidator"/></property>
              <property name="formView"><value>contactos/editarContacto</value></property>
              <property name="successView"><value>redirect&#58;clientes/editarCliente.html</value></property>
              <property name="dbManagerArs">
                  <ref bean="arsTarget"/>
      And I get the success view on my Controller with this:
      return new ModelAndView&#40;new RedirectView&#40;getSuccessView&#40;&#41;&#41;&#41;;
      But when I execute this action, nothing happends. I get a "Not found page" on my navigator. I can't understand it, because i've all the necessary url mappings, and my Tomcat's log doesn't say me any problem


      • #4
        return new ModelAndView(new RedirectView(getSuccessView()));
        You don't need to redirect it again here, since you've done it (redirect:...)in your config file.



        • #5
          Ok!! It works now!! My errors were that:
          - weren't putting ".htm" on the success view tag at ...-servlet.xml
          - using new RedirectView on the Controller side and "redirect:" on the xml side. I've change it, not using "redirect:"

          Thanks a lot!!!


          • #6
            I run into the same scenairo this afternoon. After read this thread, I change the successView field of the first form with the redirect tag. It works very well. Thanks all for your helpful information.


            • #7