View Full Version : How to return to form view when form is in multiple views?
2devnull
Sep 2nd, 2004, 10:20 AM
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?
2devnull
Sep 2nd, 2004, 11:00 AM
Here is how I got around it, hope there is a better way.
<form action="$rc.getContextPath()/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="">
</form>
In controller
--------------------
return new ModelAndView(new RedirectView(RequestUtils.getStringParameter(reque st, "href", "/index.htm")));
gmatthews
Sep 12th, 2004, 09:04 PM
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.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.