Announcement Announcement Module
Collapse
No announcement yet.
Chanining 2 SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Chanining 2 SimpleFormController

    What is the right way to chain 2 controller(subclasses of SimpleFormController)?

    Below is the scenario and requirements:

    1. LoginController(extends SimpleFormController) and has methods onSubmit(params..), formBackingObject(params ..) and referenceData(params..)

    2. HomeController (extends SimpleFormController) and has methods: onSubmit(params..), formBackingObject(params ..) and referenceData(params..) methods which it uses to display a Two.jsp(it has a form:form and other element).

    3. In LoginController, the onSubmit() method should transfer control to HomeController, so that HomeController can render a jsp after executing methods defined in it(see 2) to display Homepage.jsp.

    I tried using redirect and forward, but the jsp mentioned in HomeController successView is the one getting displayed, I need ControllerTwo to render a page(Homepage.jsp) normally(after executing formBackingObject n referenceData methods)

    Here is the xml file.

    <bean class="org.springframework.web.servlet.mvc.support .ControllerClassNameHandlerMapping" >
    <property name="pathPrefix" value="/project"/>

    </bean>


    <bean class="com.one.HomeController">
    <property name="formView" value="Homepage" />
    <property name="successView" value="CustomerSuccessTest" />

    <!-- Map a validator -->
    <property name="validator">
    <bean class="com.one.CustomerValidator" />
    </property>
    </bean>




    <bean class="com.one.LoginController">
    <property name="formView" value="CustomerForm" />
    <property name="successView" value="forward:/home" /> // Giving control to HomeController.

    <!-- Map a validator -->
    <property name="validator">
    <bean class="com.one.CustomerValidator" />

    </property>
    </bean>

    <!-- Register the Customer.properties -->
    <bean id="messageSource"
    class="org.springframework.context.support.Resourc eBundleMessageSource">
    <property name="basename" value="com/one/Customer" />
    </bean>


    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.Intern alResourceViewResolver" >
    <property name="prefix" value="/WEB-INF/pages/"/>
    <property name="suffix" value=".jsp"/>

    </bean>
    Last edited by AdityaSpring; Jan 9th, 2013, 12:36 AM. Reason: Providing more info.

  • #2
    Added the below method and it worked.

    @Override
    protected boolean isFormSubmission(HttpServletRequest request){
    return conditional false/true ; //false when request is not for form submission. true otherwise.
    }

    Please suggest a better solution if any.

    Comment

    Working...
    X