Meaningless Drivel is fun!*
The moose likes Struts and the fly likes multiple form related (wizard) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "multiple form related (wizard)" Watch "multiple form related (wizard)" New topic
Author

multiple form related (wizard)

Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
Hi there,
I'm trying to find some example on internet regarding have multiple forms related between eachother, something like a wizard, where the user submit his data first and than other details on a second page.

What I'm trying to figure out, is a way to pass the all data to my action class only when the last form has been validated.
I found something regarding validation and an attribute called "page" and another artcle about nested tags.

What's the best approach?

Thanks in advance


trying to decode a woman mind....
Dom Lassy
Ranch Hand

Joined: May 05, 2006
Posts: 181
You can use multiple forms in session scope. On each page you submit to the action that loads the next page and the data is saved in the session. After the final action, you can manually validate the contents of the forms.

If you want to aviod session scope, you can create 1 form (using request scope and used in all of the wizard actions) that is a superset of all of the forms that you would put in session using the above method. Then, on each sucessive page of the wizard, use hidden fields to retain all of the data that has already been entered.

I try not to put anything unnecessary in session, so I would use the second method.
ameya n
Greenhorn

Joined: May 14, 2007
Posts: 17
thanks a lot it was of great help
Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
Once the first step is submit the request get to the ActionForward and send it back to the second step (the one which should have some hidden fields prepolutated).

Would you give an example on how to retrieve a single field with taglibs?
Thanks for your help.
Alessandro Ilardo
Ranch Hand

Joined: Dec 23, 2005
Posts: 218
I'm trying to achieve what mentioned here above, but it doesn't work leaving the hidden tags like

<nested:hidden property="email" />

I'm trying to retain data in this way, but it doesn't work either



17:32:27,681 ERROR [InsertTag] ServletException in '/WEB-INF/jsp/registration/partner/step2.jsp': userDataForm
org.apache.jasper.JasperException: Exception in JSP: /WEB-INF/jsp/registration/partner/step2.jsp:44

42
43:
44: <jsp:useBean id="prevForm" scope="request" type="org.apache.struts.action.ActionForm" beanName="userDataForm" />
45:
46: <nested:hidden property="username" value="${prevForm.username}" />



Can anyone show me how to retain the value from the previous form?

[ May 24, 2007: Message edited by: Alessandro Ilardo ]
[ May 24, 2007: Message edited by: Alessandro Ilardo ]
Sam Sunamin
Ranch Hand

Joined: Mar 16, 2007
Posts: 113
Using the same form and using normal hidden field
<html:hidden property="page" value="2" />
<html:hidden property="product" />
<html:hidden property="DDPlan" />
<html:hidden property="email" />


Yours Sam<br />SCJP5.0 97%<br />SCBCD5.0 72%
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
Actually, there are some open source projects that can probably do this for you (if you haven't already completed it). If you have any sort of semi-complex wizard, you should check out

http://wiki.java.net/bin/view/Projects/EasyWizard

I've used this one for a project and worked pretty seamlessly.
 
wood burning stoves
 
subject: multiple form related (wizard)