This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Nested Forms

Dec 27th, 2004, 07:03 PM

Hello,

I have a form process that extends AbstractWizardFormController. But while processing things within the wizard form, I want to put a link to start off different form process (may be a simpleform or wizardform).

For an example, I have a customer wizard form. And while a user is stepping thru entering info on the Customer paneles, I want to have a link to start address wizard form that will allow to create address book entry (and suppose Customer does not have Address as a part of Customer command object).

What I would like to know is, suppose I have above implementation, how could I come back to customer wizard form when the address form submission is completed successfully?

I can think of a couple of different solutions; most revolve around saving state somewhere; and coding the other form to have a "returnTo" parameter.

While session timeouts and server load might become a concern you could always just put the wizard contents into a session attribute so you can get them back.

You might be able to either breakup the wizard transaction into pre/post states; or simply add some means (like an extra DB) table to store the incomplete state - then when/if the user returns to the wizard flow you can restore the state from server-side, even if the user's session timed out - depending on the amount of information and its sensitivity you could also store it as a cookie in the user's browser.

As for the work flow - I haven't had time recently to look at any of the web navigation flow libraries; but you will obviously need some way to tell the "Add Address" page what to return/forward to apon completion. I'd tend to use a simple "returnTo" parameter (with wizard object's information as a query-string parameter) to tell the address controller what to do when completing (with a sensible default like the main page). This brings up an interesting point that I've seen a couple of times before, but have never found a solution that I really like - maybe someone knows a navigation flow library that helps out with managing this?

Comment

Webflow is not an easy thing to handle with spring, there is an open source project which I think does the job well, it is the springwebflow but I did not try to use it.

From my own experience, and I used only the AstractWizardFormController, if you want to leave the wizard and forward to another controller, you can have a hidden field named _finish that you enabled by javascript, and a field named nextController which will tell which controller you want to forward to. After posting, it will execute the processFinish method of your wizard. With correct parameters in the request, your can forward to the next controller, after persisting your data.
To come back to your Customer Workflow, you will have to have parameters in your request to tell which page you want to come back to on your controller. This parameter will be decoded in the method getInitalPage that you will override to display the correct page.

to come back to the 2nd page of your abstract wizard controller Customer, after having inputed the address, you could do something like that after forwarding to MyCustomerWizardController.html?address=complete.