Announcement Announcement Module
Collapse
No announcement yet.
Setting render parameters in SimpleFormController Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting render parameters in SimpleFormController

    Good day,

    I'm using a SimpleFormController to submit a form, perform validations and then route it to a success view. I need to pass a parameter back to the successview. At this stage my controller only contains the formBackingObject method. What other methods do I need to send a parameter back? I understand I need to use the response.setRenderParameter - but inside which method? I've tried all the methods (one at a time) of the simpleformcontroller as well as the abstractController, but it does not go into these methods at all.

    My controller is defined as follows:

    <bean id="updateServiceAccountController"
    class="cmss.controllers.UpdateServiceAccountContro ller">

    <property name="sessionForm" value="true"/>
    <property name="commandName" value="serviceAccount"/>
    <property name="commandClass" value="cmss.formobjects.UpdateServiceAccountFormOb ject"/>
    <property name="formView" value="updateServiceAccount"/>
    <property name="successView" value="manageServiceAccount"/>
    <property name="validateOnBinding" value="true"/>
    <property name="validator">
    <ref bean="updateServiceAccountValidator"/>
    </property>
    </bean>

    Thank you!
    Hanlie

  • #2
    When you need to include things in the success view, you should create a Model, put things into it, and then return the Model with the successView name.

    try: return new ModelAndView(getSuccessView(), "parameter", foo);

    Are you trying to redirect on success? If so, the model parameters will be encoded into the query string.

    If you are not trying to redirect, then all of your model parameters will simply be bound into the request attributes (if you are using JSP, for instance).

    Comment


    • #3
      Hi,
      you have to override the onSubmitAction method in the controller. See below.


      public void onSubmitAction(ActionRequest request, ActionResponse response,
      Object command, BindException errors) throws Exception {

      System.out.println("############### onSubmitAction");
      response.setRenderParameter("serviceIndex", request.getParameter("serviceIndex"));
      }

      Comment

      Working...
      X