1 ActionForm and 3 Action objects. The reason for the 3 actions is it gives you flexibility in your business implementation. I personally would not do any business logic till i have all values in hand. So ActionObject1 and ActionObject2 will just send the user to the correct next pages. It is in Action3 that you would finally do business implementation (like update database etc..)
 
A dirty flag is nothing but a hidden variable in a jsp page. Every time the user submits information, the value of this hidden variable is checked. Based on the value, the corresponding error check is done. I believe somebody in the mailing list have coined the term 'dirtyFlag' because it is not that elegant a way of doing it. Maybe some experts in this group will come with a better alternative. If so i am willing to experiment with that alternative.
 
For example.. If you have  Page 1  - contains firstName, lastName
                                      Page 2  - contains Phone Number and Address
                                      Page 3 - contains  Personal Interests and maybe CC no
 
You would set a hidden variable in all 3 pages. Same name but different values in the 3 pages. Your form would have a private variable which is the name of the hidden variable.
 
When the user submits info.. (say from page 1), in your ActionForm  the value of the dirtyFlag is set to page1. In your validate method you would do a conditional statement 
 if(dirtyFlag equals page1)    { check for firstName and lastName values for errors. If errors occur struts will send you back to Page1 else struts will take you back to normal processing}
 if(dirtyFlag equals page2)    { check for phone # and Address values for errors. If errors occur struts will send you back to Page2  else struts will take you back to normal processing}
 if(dirtyFlag equals page3)    { check for all values. If errors occur struts will send you back to Page3. else struts will continue with normal processing}
                               
The reson you are checking for all the values (in page 3 submit) is to satisfy yourself that all values are entered properly. If in page1 and page 2 you encounter errors, struts will automatically send you to the correct page.
 
 
-----Original Message-----
From: Jonathan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 5:17 PM
To: [EMAIL PROTECTED]
Subject: Re: *** implementing consecutive form validation? ***

Can you elaborate?  Are you saying 1 ActionForm and 3 Action objects?  Do you validate in the ActionForm or in the Action?  Can you please explain the "dirty flags" technique?
----- Original Message -----
Sent: Tuesday, April 24, 2001 3:38 PM
Subject: RE: *** implementing consecutive form validation? ***

Try using a single Form but 3 different Actions (for flexibility). The form is send from page to page. Set a dirtyflag in the form which checks what page the user is in. Based on that value, do the corresponding validation in the Form.
 
Amar..
-----Original Message-----
From: Jonathan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, April 24, 2001 3:35 PM
To: [EMAIL PROTECTED]
Subject: *** implementing consecutive form validation? ***

 
If a form is made up of three consecutive pages and I want to validate page by page, how should I go about doing this?  Do I use three ActionForms and one Action?  Do I use the validation the ActionForm offers for basic validation?  Do I fill one ActionForm's validation method with "if/then" statements to test if I am on the first, second, or third page of the form and then use the Action's validate method at the end?
I was interested in what you all were implementing.
Cheers
 
Jonathan

Reply via email to