Results 1 to 7 of 7

Thread: Sharing Command object between SimpleFormControllers

  1. #1

    Default 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. #2

    Default 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.

  3. #3
    Join Date
    Aug 2004
    Location
    Philadelphia, PA
    Posts
    14

    Default

    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.

  4. #4
    Join Date
    Apr 2006
    Posts
    166

    Default

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

  5. #5

    Default 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?

  6. #6
    Join Date
    Apr 2006
    Posts
    166

    Default

    I think that in your case, AbstractWizardFormController is good choice

  7. #7
    Join Date
    Apr 2005
    Location
    Finland
    Posts
    314

    Default

    Quote 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).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •