Results 1 to 7 of 7

Thread: Call from a Form to another Form

  1. #1
    Join Date
    Apr 2005
    Posts
    20

    Default 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:
    Code:
    return new ModelandView("mysecondform","model",model);
    it will go directly to the view, giving me an exception, not passing around the "formBackingObject" method.
    :?:

  2. #2
    Join Date
    Nov 2004
    Location
    Dallas, TX (USA)
    Posts
    58

    Default

    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...
    Code:
     <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>
    </bean>
    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

    HTH

  3. #3
    Join Date
    Apr 2005
    Posts
    20

    Default

    Thanks dhainlin

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

    Code:
    <!--  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"/>
            </property>
        </bean>
    And I get the success view on my Controller with this:
    Code:
    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. #4
    Join Date
    Oct 2004
    Location
    Palmas-TO, Brazil
    Posts
    92

    Default

    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.

    Gilberto

  5. #5
    Join Date
    Apr 2005
    Posts
    20

    Default

    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. #6

    Default

    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. #7
    Join Date
    Apr 2005
    Posts
    20

    Default


Similar Threads

  1. Replies: 3
    Last Post: Jun 8th, 2010, 03:27 AM
  2. Replies: 6
    Last Post: Sep 22nd, 2006, 09:08 AM
  3. Replies: 9
    Last Post: May 4th, 2006, 09:53 AM
  4. Replies: 0
    Last Post: Jun 10th, 2005, 08:22 AM
  5. Replies: 2
    Last Post: Sep 2nd, 2004, 08:18 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
  •