Announcement Announcement Module
Collapse
No announcement yet.
Sharing Command object between SimpleFormControllers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sharing Command object between SimpleFormControllers

    I have a Spring MVC application with a SimpleFormController (A). A's successView (B) should be a SimpleFormController itself, and should share the A's Command object as well as the model data that A returns in its onSubmit method ( return new ModelAndView(getSuccessView(), "model", model).addObject(command); ).
    I have tried to solve this by using a RedirectView, but neither the Command object or the model data seem to be available in B's formView.
    How could I solve this?
    Do I have to use a wizard controller?

  • #2
    AbstractWizardFormController is probably the answer

    As far as I can see, AbstractWizardFormController is a solution. See http://www.devx.com/Java/Article/22134/0/page/5.

    Comment


    • #3
      There are other ways but wizard controller is very easy to use and seems to be what you need. It's very easy to use the only problems i've had with it are related to customized back behavior.

      Comment


      • #4
        Hi
        What about using session in this case. I use session and it work OK
        Last edited by shoa; Sep 27th, 2006, 05:46 PM.

        Comment


        • #5
          Session, how?

          How do you use session, could you please explain?

          I figured that doing a redirect to a(nother) SimpleFormController of course ends up with an action for the new Form view to be a HTTP GET (as a result of the redirect), which means that I can do a POST to the SimpleFormController.
          Could this be overridden in any way, or is wizard controller the answer?

          Comment


          • #6
            I think that in your case, AbstractWizardFormController is good choice

            Comment


            • #7
              Originally posted by mortenhaugen View Post
              How do you use session, could you please explain?

              I figured that doing a redirect to a(nother) SimpleFormController of course ends up with an action for the new Form view to be a HTTP GET (as a result of the redirect), which means that I can do a POST to the SimpleFormController.
              Could this be overridden in any way, or is wizard controller the answer?
              In your first SimpleFormController's onSubmit()-method put your model-object to HttpSession:

              req.getSession().setAttribute("model", yourModel);

              and in the 2nd SimpleFormController's formBackingObject() -method read the object from the session by

              YourModel model = (YourModel) req.getSession().getAttribute("model");

              Beware that formBackinObject() method is called both on form open (request) and on form submit (post).

              Comment

              Working...
              X