Announcement Announcement Module
No announcement yet.
How to return to form view when form is in multiple views? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to return to form view when form is in multiple views?

    If you have a form on multiple pages that post to a particualr controller, how do you determine the view that posted the form so as to return to that view?

  • #2
    Here is how I got around it, hope there is a better way.

    <form action="$rc.getContextPath&#40;&#41;/cart/addtocart.htm" method="post" enctype="application/x-www-form-urlencoded" name="shopcart" onSubmit="document.shopcart.href.value=location.href;">
    <input type="hidden" name="href" value="">

    In controller
    return new ModelAndView&#40;new RedirectView&#40;RequestUtils.getStringParameter&#40;request, "href", "/index.htm"&#41;&#41;&#41;;


    • #3
      AbstractWizardFormController is designed to handle this.

      It probably should be called AbstractMultiViewFormController since while it does contain the concept of Finish and Cancel, it also does *not* force you to make your view look like a wizard.

      e.g. you could make your view look like tabbed pages, or use other buttons to move between the different views.

      You use name="_target0", "_target1", "target2" (for pages 1,2,3, ...) in form input fields to tell the controller which view to show, and configure the view names in the spring config file via the "pages" property.

      Probably easiest to just read the source code for it but sounds like what you want.