Announcement Announcement Module
Collapse
No announcement yet.
SimpleFormController with itself as the success view Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleFormController with itself as the success view

    I have a SimpleFormController that is coming up fine on the page. There are several forms on the page, so when one is submitted, I want to save the data on it and return to the same page. The first submit worked fine, and I finally ended up with
    Code:
    return new ModelAndView(getSuccessView(), myModel);
    and the jsp listed in the xml instead of the command name to get back to the form (to do this I had to repopulate all of my lists and my backing object because neither the formBackingObject function nor the referenceData function were called the second time around.) However, when I clicked submit on another form, the formBackingObject function ran before onSubmit(!?) 1. Is there a better way for the form to forward to itself (nothing else I tried worked) and why is formBackingObject called after I submit?

    Thanks!

  • #2
    Well you are only returning "myModel" so it won't contain anything unless you have actually populated it.

    It would be better for the success view to do a forward, or a redirect back to that controller. That will cause it to go through the correct sequence of things. At the moment you are not going back to the controller, you are simply going to a view, which I suspect is a simple jsp. Your view wants to call the controller, via forward or redirect.

    Comment


    • #3
      I had tried that before and got:

      javax.servlet.ServletException: Could not resolve view with name 'successview.htm' in servlet with name 'appname'.

      I tried again and got the same error.

      Comment


      • #4
        OOPS - ignore that last post (I forgot to change back to a redirect.) The actual error was that it was not getting my parameter - I need to retrieve a particular record from the database.

        Comment


        • #5
          Nevermind... I had an afterthought to append the '?param=value' to the redirect and it seems to work fine (no errors for now at least). thanks...

          Comment


          • #6
            All views are rendered with the model, so redirect url will call toString on every object in the model and set it with the toString value on the url. In otherwords, just include that param in the model and it will work

            Comment

            Working...
            X