You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Frank W. Zammetti" <fz...@omnytex.com> on 2005/11/16 19:46:15 UTC

Wizard page "data corruption" (was: "Re: Form Beans")

Imagine you have a single ActionForm with a firstName field.  Now 
imagine you have two wizard pages that are used in sequence, and you 
want to use the same ActionForm for both.

Assume the form is stored in session, as you would expect in a wizard.

Now, imagine there is a firstName field on both HTML forms of both 
wizard pages... you might argue this isn't a good wizard design, and I 
would tend to agree, but it's something that can happen in some cases.

Now, assume a prototypical Struts app, no Struts Dialogs extensions or 
anything...

What happens when the first page submits?  The firstName field is 
populated in the ActionForm.  Now what about when the second form is 
submitted?  The value of the firstName field in the ActionForm now has 
the value from the second form submission, effectively overwriting the 
value the user entered on the first page, so if the user were to go back 
to the first wizard page, they would incorrectly see the data from the 
second page in effect.  Easily to explain, but to the user it's a data 
corruption issue.

This is the scenario I was referring to.  Does your Dialogs stuff 
overcome that?  If so, how?  Whether it does or not, a "normal" Struts 
app will certainly have this problem, hence my comment about making sure 
the field names are different... in this case, it might be as simple as 
making two fields in the ActionForm, one named firstNamePage1 and 
firstNamePage2.

Frank

Michael Jouravlev wrote:
> On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> 
>>The one thing to keep in mind if you go [one ActionForm] route is
>>to be sure you don't have a field on one page
>>with the same name as another.  I had one junior developer make that
>>mistake and it drove him nuts trying to figure out what was wrong
>>(obvious in retrospect, but one of those "tricky at the time" problems
>>to solve).
> 
> 
> I don't see right away how does this matter if you have separate
> submits from a browser each time. Also would not matter if you
> redirect between pages and don't intentionally stuff values into
> redirected request. Redirected request comes clean, so same fields or
> not - does not matter. This is why my two-phase request processing
> works: POST comes with input data, form is populated, then I redirect
> to the same action again, GET comes clean, form is not updated because
> request contains no data.
> 
> Forwarded request brings all input data with it, and Struts applies
> this data to another form. Been there ;)
> 
> Michael.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Wizard page "data corruption"

Posted by Yujun Liang <yu...@acm.org>.
Frank,

If the firstNames are different on wizard forms, it should be designed as

The first page has this in the form:
<input type="text" name="firstName[1]">

The second page has this:
<input type="text" name="firstName[2]">


Regards

On 11/17/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>
> bsimonin@psl.nmsu.edu wrote:
> > But the point of the wizard is to share data between the pages.
>
> In a sense that's true, but I think the larger point of a wizard is to
> collect a batch of information by breaking it up into smaller chunks and
> allowing the user to deal with the smaller chunks rather than the whole
> batch at one time. That's the important thing to me, and in this
> regard, sharing between pages isn't really important (or desireable
> potentially).
>
> I agree with you and Michael, but the thing that was confusing me, well,
> two things I guess, is (a) the problem I previously saw and helped a
> colleague resolve, which in retrospect doesn't make much sense, and (b)
> the fact that in my mind, when you go through a wizard, more times than
> not you probably *won't* see data you entered on a subsequent page again
> until the end.
>
> In other words, you enter some data on page 1, page 2 appears with
> completely different data, and so on, until the end where generally you
> have some confirmation page that summarizes what you entered on all the
> pages and lets you commit it. In that sense, sharing doesn't really
> come into the picture, and so a field with the same name on two screens
> is in a way incorrect.
>
> Again though, I don't disagree with you or Michael, it's just a
> different perspective :)
>
> > --Brad
>
> Frank
>
>
>
>
>
> >
> > -----Original Message-----
> > From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> > Sent: Wed 11/16/2005 12:23 PM
> > To: Struts Users Mailing List
> > Subject: Re: Wizard page "data corruption"
> >
> > No, I think you misunderstood :)
> >
> > Let's say we are designing a wizard flow with three pages, plus one
> > "confirmation" page at the end. Each page has a single HTML form on it.
> > The first page has this in the form:
> >
> > <input type="text" name="firstName">
> >
> > The second page has this:
> >
> > <input type="text" name="firstName">
> >
> > And the third page has:
> >
> > <input type="text" name="lastName">
> >
> > (We're going to ignore the poor wizard design for the moment, we're
> > talking theory here :) ).
> >
> > Now, let's say for the sake of simplicity you decide you want to have a
> > single ActionForm for all three pages. This isn't an unusual approach
> > for wizards. So, your ActionForm might look like:
> >
> > public class myForm extends ActionForm {
> > private String firstName;
> > private String lastName;
> > // Getters and setter follow
> > }
> >
> > Lastly, assume that all the action mappings involved here reference the
> > same session-scoped ActionForm, which is exactly what we intend (think
> > of the ActionForm as collecting all the input through the entire wixard
> > flow). Now, let's walk through what happens:
> >
> > * Page 1 is shown, user enters "Frank" in firstName textbox. User
> > clicks submit.
> >
> > * At this point, the ActionForm in session now has firstName="Frank".
> >
> > * Page 2 is shown. User now enters "Brad" in firstName textbox. User
> > clicks submit.
> >
> > * At this point, the ActionForm in session now has firstName="Brad".
> >
> > * Page 3 is shown. User enters "Zammetti" in lastName textbox. User
> > clicks submit.
> >
> > * At this point, the ActionForm in session now has lastName="Zammetti".
> >
> > * The confirmation page is shown. Let's say that there is a button to
> > go back to page 1 now, and the user does so. What do they see? They
> > see "Brad" in the firstName field, even though on page 1 they entered
> > "Frank". It's easy to see why it happened, but to the user their data
> > got corrupted.
> >
> > Again, you have to ignore the bad wizard design... I'm just too lazy to
> > think of a better example :)
> >
> > That's the scenario I was referring to. Does that make sense? :)
> >
> > Frank
> >
> > bsimonin@psl.nmsu.edu wrote:
> >
> >>I hope I understand what you are asking. A couple of things come to mind
> about threads and Servlets. If one uses Instance variables in Servlets then
> each instance of that Servlet has a unique variable and there is no data
> corruption. However if one uses Class variables then each instance of a
> servlet shares the variables and then data corruption can occur.
> >>
> >>Same with formbeans and wizards. Each formbean is unique to the specific
> Servlet action. So, if one uses a single formbean for several steps in a
> wizard then there is no data corruption.
> >>
> >>Am I understanding what you are asking?
> >>
> >>--Brad.
> >>
> >>
> >>
> >>-----Original Message-----
> >>From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> >>Sent: Wed 11/16/2005 11:46 AM
> >>To: Struts Users Mailing List
> >>Subject: Wizard page "data corruption" (was: "Re: Form Beans")
> >>
> >>Imagine you have a single ActionForm with a firstName field. Now
> >>imagine you have two wizard pages that are used in sequence, and you
> >>want to use the same ActionForm for both.
> >>
> >>Assume the form is stored in session, as you would expect in a wizard.
> >>
> >>Now, imagine there is a firstName field on both HTML forms of both
> >>wizard pages... you might argue this isn't a good wizard design, and I
> >>would tend to agree, but it's something that can happen in some cases.
> >>
> >>Now, assume a prototypical Struts app, no Struts Dialogs extensions or
> >>anything...
> >>
> >>What happens when the first page submits? The firstName field is
> >>populated in the ActionForm. Now what about when the second form is
> >>submitted? The value of the firstName field in the ActionForm now has
> >>the value from the second form submission, effectively overwriting the
> >>value the user entered on the first page, so if the user were to go back
> >>to the first wizard page, they would incorrectly see the data from the
> >>second page in effect. Easily to explain, but to the user it's a data
> >>corruption issue.
> >>
> >>This is the scenario I was referring to. Does your Dialogs stuff
> >>overcome that? If so, how? Whether it does or not, a "normal" Struts
> >>app will certainly have this problem, hence my comment about making sure
> >>the field names are different... in this case, it might be as simple as
> >>making two fields in the ActionForm, one named firstNamePage1 and
> >>firstNamePage2.
> >>
> >>Frank
> >>
> >>Michael Jouravlev wrote:
> >>
> >>
> >>>On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >>>
> >>>
> >>>
> >>>>The one thing to keep in mind if you go [one ActionForm] route is
> >>>>to be sure you don't have a field on one page
> >>>>with the same name as another. I had one junior developer make that
> >>>>mistake and it drove him nuts trying to figure out what was wrong
> >>>>(obvious in retrospect, but one of those "tricky at the time" problems
> >>>>to solve).
> >>>
> >>>
> >>>I don't see right away how does this matter if you have separate
> >>>submits from a browser each time. Also would not matter if you
> >>>redirect between pages and don't intentionally stuff values into
> >>>redirected request. Redirected request comes clean, so same fields or
> >>>not - does not matter. This is why my two-phase request processing
> >>>works: POST comes with input data, form is populated, then I redirect
> >>>to the same action again, GET comes clean, form is not updated because
> >>>request contains no data.
> >>>
> >>>Forwarded request brings all input data with it, and Struts applies
> >>>this data to another form. Been there ;)
> >>>
> >>>Michael.
> >>>
> >>>---------------------------------------------------------------------
> >>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>>For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
>
> --
> Frank W. Zammetti
> Founder and Chief Software Architect
> Omnytex Technologies
> http://www.omnytex.com
> AIM: fzammetti
> Yahoo: fzammetti
> MSN: fzammetti@hotmail.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


--
Yujun Liang
yujun.liang@acm.org

Re: Wizard page "data corruption"

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
bsimonin@psl.nmsu.edu wrote:
> But the point of the wizard is to share data between the pages.  

In a sense that's true, but I think the larger point of a wizard is to 
collect a batch of information by breaking it up into smaller chunks and 
allowing the user to deal with the smaller chunks rather than the whole 
batch at one time.  That's the important thing to me, and in this 
regard, sharing between pages isn't really important (or desireable 
potentially).

I agree with you and Michael, but the thing that was confusing me, well, 
two things I guess, is (a) the problem I previously saw and helped a 
colleague resolve, which in retrospect doesn't make much sense, and (b) 
the fact that in my mind, when you go through a wizard, more times than 
not you probably *won't* see data you entered on a subsequent page again 
until the end.

In other words, you enter some data on page 1, page 2 appears with 
completely different data, and so on, until the end where generally you 
have some confirmation page that summarizes what you entered on all the 
pages and lets you commit it.  In that sense, sharing doesn't really 
come into the picture, and so a field with the same name on two screens 
is in a way incorrect.

Again though, I don't disagree with you or Michael, it's just a 
different perspective :)

> --Brad 

Frank





> 
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> Sent: Wed 11/16/2005 12:23 PM
> To: Struts Users Mailing List
> Subject: Re: Wizard page "data corruption"
>  
> No, I think you misunderstood :)
> 
> Let's say we are designing a wizard flow with three pages, plus one 
> "confirmation" page at the end.  Each page has a single HTML form on it. 
>   The first page has this in the form:
> 
> <input type="text" name="firstName">
> 
> The second page has this:
> 
> <input type="text" name="firstName">
> 
> And the third page has:
> 
> <input type="text" name="lastName">
> 
> (We're going to ignore the poor wizard design for the moment, we're 
> talking theory here :) ).
> 
> Now, let's say for the sake of simplicity you decide you want to have a 
> single ActionForm for all three pages.  This isn't an unusual approach 
> for wizards.  So, your ActionForm might look like:
> 
> public class myForm extends ActionForm {
>    private String firstName;
>    private String lastName;
>    // Getters and setter follow
> }
> 
> Lastly, assume that all the action mappings involved here reference the 
> same session-scoped ActionForm, which is exactly what we intend (think 
> of the ActionForm as collecting all the input through the entire wixard 
> flow).  Now, let's walk through what happens:
> 
> * Page 1 is shown, user enters "Frank" in firstName textbox.  User 
> clicks submit.
> 
> * At this point, the ActionForm in session now has firstName="Frank".
> 
> * Page 2 is shown.  User now enters "Brad" in firstName textbox.  User 
> clicks submit.
> 
> * At this point, the ActionForm in session now has firstName="Brad".
> 
> * Page 3 is shown.  User enters "Zammetti" in lastName textbox.  User 
> clicks submit.
> 
> * At this point, the ActionForm in session now has lastName="Zammetti".
> 
> * The confirmation page is shown.  Let's say that there is a button to 
> go back to page 1 now, and the user does so.  What do they see?  They 
> see "Brad" in the firstName field, even though on page 1 they entered 
> "Frank".  It's easy to see why it happened, but to the user their data 
> got corrupted.
> 
> Again, you have to ignore the bad wizard design... I'm just too lazy to 
> think of a better example :)
> 
> That's the scenario I was referring to.  Does that make sense? :)
> 
> Frank
> 
> bsimonin@psl.nmsu.edu wrote:
> 
>>I hope I understand what you are asking.  A couple of things come to mind about threads and Servlets.  If one uses Instance variables in Servlets then each instance of that Servlet has a unique variable and there is no data corruption.  However if one uses Class variables then each instance of a servlet shares the variables and then data corruption can occur. 
>>
>>Same with formbeans and wizards.  Each formbean is unique to the specific Servlet action.  So, if one uses a single formbean for several steps in a wizard then there is no data corruption.
>>
>>Am I understanding what you are asking?
>>
>>--Brad. 
>>
>>
>>
>>-----Original Message-----
>>From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
>>Sent: Wed 11/16/2005 11:46 AM
>>To: Struts Users Mailing List
>>Subject: Wizard page "data corruption" (was: "Re: Form Beans")
>> 
>>Imagine you have a single ActionForm with a firstName field.  Now 
>>imagine you have two wizard pages that are used in sequence, and you 
>>want to use the same ActionForm for both.
>>
>>Assume the form is stored in session, as you would expect in a wizard.
>>
>>Now, imagine there is a firstName field on both HTML forms of both 
>>wizard pages... you might argue this isn't a good wizard design, and I 
>>would tend to agree, but it's something that can happen in some cases.
>>
>>Now, assume a prototypical Struts app, no Struts Dialogs extensions or 
>>anything...
>>
>>What happens when the first page submits?  The firstName field is 
>>populated in the ActionForm.  Now what about when the second form is 
>>submitted?  The value of the firstName field in the ActionForm now has 
>>the value from the second form submission, effectively overwriting the 
>>value the user entered on the first page, so if the user were to go back 
>>to the first wizard page, they would incorrectly see the data from the 
>>second page in effect.  Easily to explain, but to the user it's a data 
>>corruption issue.
>>
>>This is the scenario I was referring to.  Does your Dialogs stuff 
>>overcome that?  If so, how?  Whether it does or not, a "normal" Struts 
>>app will certainly have this problem, hence my comment about making sure 
>>the field names are different... in this case, it might be as simple as 
>>making two fields in the ActionForm, one named firstNamePage1 and 
>>firstNamePage2.
>>
>>Frank
>>
>>Michael Jouravlev wrote:
>>
>>
>>>On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>
>>>
>>>
>>>>The one thing to keep in mind if you go [one ActionForm] route is
>>>>to be sure you don't have a field on one page
>>>>with the same name as another.  I had one junior developer make that
>>>>mistake and it drove him nuts trying to figure out what was wrong
>>>>(obvious in retrospect, but one of those "tricky at the time" problems
>>>>to solve).
>>>
>>>
>>>I don't see right away how does this matter if you have separate
>>>submits from a browser each time. Also would not matter if you
>>>redirect between pages and don't intentionally stuff values into
>>>redirected request. Redirected request comes clean, so same fields or
>>>not - does not matter. This is why my two-phase request processing
>>>works: POST comes with input data, form is populated, then I redirect
>>>to the same action again, GET comes clean, form is not updated because
>>>request contains no data.
>>>
>>>Forwarded request brings all input data with it, and Struts applies
>>>this data to another form. Been there ;)
>>>
>>>Michael.
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>>>
>>
>>
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Wizard page "data corruption"

Posted by bs...@psl.nmsu.edu.
Yes now it makes sense and the Wizard is working as it should or at least as it should if you are using LookupDispatchAction (which to me is an elegant wizard solution). 

I agree with Michael Jouravlev the wizard is working as designed.  I guess you *could* put the first name on the second page of the wizard in an un-editable field or not put the first name on the second page and have the user click on the back button to the first page to change the first name if they wanted to. But the point of the wizard is to share data between the pages.  

--Brad 


-----Original Message-----
From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
Sent: Wed 11/16/2005 12:23 PM
To: Struts Users Mailing List
Subject: Re: Wizard page "data corruption"
 
No, I think you misunderstood :)

Let's say we are designing a wizard flow with three pages, plus one 
"confirmation" page at the end.  Each page has a single HTML form on it. 
  The first page has this in the form:

<input type="text" name="firstName">

The second page has this:

<input type="text" name="firstName">

And the third page has:

<input type="text" name="lastName">

(We're going to ignore the poor wizard design for the moment, we're 
talking theory here :) ).

Now, let's say for the sake of simplicity you decide you want to have a 
single ActionForm for all three pages.  This isn't an unusual approach 
for wizards.  So, your ActionForm might look like:

public class myForm extends ActionForm {
   private String firstName;
   private String lastName;
   // Getters and setter follow
}

Lastly, assume that all the action mappings involved here reference the 
same session-scoped ActionForm, which is exactly what we intend (think 
of the ActionForm as collecting all the input through the entire wixard 
flow).  Now, let's walk through what happens:

* Page 1 is shown, user enters "Frank" in firstName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has firstName="Frank".

* Page 2 is shown.  User now enters "Brad" in firstName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has firstName="Brad".

* Page 3 is shown.  User enters "Zammetti" in lastName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has lastName="Zammetti".

* The confirmation page is shown.  Let's say that there is a button to 
go back to page 1 now, and the user does so.  What do they see?  They 
see "Brad" in the firstName field, even though on page 1 they entered 
"Frank".  It's easy to see why it happened, but to the user their data 
got corrupted.

Again, you have to ignore the bad wizard design... I'm just too lazy to 
think of a better example :)

That's the scenario I was referring to.  Does that make sense? :)

Frank

bsimonin@psl.nmsu.edu wrote:
> I hope I understand what you are asking.  A couple of things come to mind about threads and Servlets.  If one uses Instance variables in Servlets then each instance of that Servlet has a unique variable and there is no data corruption.  However if one uses Class variables then each instance of a servlet shares the variables and then data corruption can occur. 
> 
> Same with formbeans and wizards.  Each formbean is unique to the specific Servlet action.  So, if one uses a single formbean for several steps in a wizard then there is no data corruption.
> 
> Am I understanding what you are asking?
> 
> --Brad. 
> 
> 
> 
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> Sent: Wed 11/16/2005 11:46 AM
> To: Struts Users Mailing List
> Subject: Wizard page "data corruption" (was: "Re: Form Beans")
>  
> Imagine you have a single ActionForm with a firstName field.  Now 
> imagine you have two wizard pages that are used in sequence, and you 
> want to use the same ActionForm for both.
> 
> Assume the form is stored in session, as you would expect in a wizard.
> 
> Now, imagine there is a firstName field on both HTML forms of both 
> wizard pages... you might argue this isn't a good wizard design, and I 
> would tend to agree, but it's something that can happen in some cases.
> 
> Now, assume a prototypical Struts app, no Struts Dialogs extensions or 
> anything...
> 
> What happens when the first page submits?  The firstName field is 
> populated in the ActionForm.  Now what about when the second form is 
> submitted?  The value of the firstName field in the ActionForm now has 
> the value from the second form submission, effectively overwriting the 
> value the user entered on the first page, so if the user were to go back 
> to the first wizard page, they would incorrectly see the data from the 
> second page in effect.  Easily to explain, but to the user it's a data 
> corruption issue.
> 
> This is the scenario I was referring to.  Does your Dialogs stuff 
> overcome that?  If so, how?  Whether it does or not, a "normal" Struts 
> app will certainly have this problem, hence my comment about making sure 
> the field names are different... in this case, it might be as simple as 
> making two fields in the ActionForm, one named firstNamePage1 and 
> firstNamePage2.
> 
> Frank
> 
> Michael Jouravlev wrote:
> 
>>On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>
>>
>>>The one thing to keep in mind if you go [one ActionForm] route is
>>>to be sure you don't have a field on one page
>>>with the same name as another.  I had one junior developer make that
>>>mistake and it drove him nuts trying to figure out what was wrong
>>>(obvious in retrospect, but one of those "tricky at the time" problems
>>>to solve).
>>
>>
>>I don't see right away how does this matter if you have separate
>>submits from a browser each time. Also would not matter if you
>>redirect between pages and don't intentionally stuff values into
>>redirected request. Redirected request comes clean, so same fields or
>>not - does not matter. This is why my two-phase request processing
>>works: POST comes with input data, form is populated, then I redirect
>>to the same action again, GET comes clean, form is not updated because
>>request contains no data.
>>
>>Forwarded request brings all input data with it, and Struts applies
>>this data to another form. Been there ;)
>>
>>Michael.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Wizard page "data corruption"

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
No, I think you misunderstood :)

Let's say we are designing a wizard flow with three pages, plus one 
"confirmation" page at the end.  Each page has a single HTML form on it. 
  The first page has this in the form:

<input type="text" name="firstName">

The second page has this:

<input type="text" name="firstName">

And the third page has:

<input type="text" name="lastName">

(We're going to ignore the poor wizard design for the moment, we're 
talking theory here :) ).

Now, let's say for the sake of simplicity you decide you want to have a 
single ActionForm for all three pages.  This isn't an unusual approach 
for wizards.  So, your ActionForm might look like:

public class myForm extends ActionForm {
   private String firstName;
   private String lastName;
   // Getters and setter follow
}

Lastly, assume that all the action mappings involved here reference the 
same session-scoped ActionForm, which is exactly what we intend (think 
of the ActionForm as collecting all the input through the entire wixard 
flow).  Now, let's walk through what happens:

* Page 1 is shown, user enters "Frank" in firstName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has firstName="Frank".

* Page 2 is shown.  User now enters "Brad" in firstName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has firstName="Brad".

* Page 3 is shown.  User enters "Zammetti" in lastName textbox.  User 
clicks submit.

* At this point, the ActionForm in session now has lastName="Zammetti".

* The confirmation page is shown.  Let's say that there is a button to 
go back to page 1 now, and the user does so.  What do they see?  They 
see "Brad" in the firstName field, even though on page 1 they entered 
"Frank".  It's easy to see why it happened, but to the user their data 
got corrupted.

Again, you have to ignore the bad wizard design... I'm just too lazy to 
think of a better example :)

That's the scenario I was referring to.  Does that make sense? :)

Frank

bsimonin@psl.nmsu.edu wrote:
> I hope I understand what you are asking.  A couple of things come to mind about threads and Servlets.  If one uses Instance variables in Servlets then each instance of that Servlet has a unique variable and there is no data corruption.  However if one uses Class variables then each instance of a servlet shares the variables and then data corruption can occur. 
> 
> Same with formbeans and wizards.  Each formbean is unique to the specific Servlet action.  So, if one uses a single formbean for several steps in a wizard then there is no data corruption.
> 
> Am I understanding what you are asking?
> 
> --Brad. 
> 
> 
> 
> -----Original Message-----
> From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
> Sent: Wed 11/16/2005 11:46 AM
> To: Struts Users Mailing List
> Subject: Wizard page "data corruption" (was: "Re: Form Beans")
>  
> Imagine you have a single ActionForm with a firstName field.  Now 
> imagine you have two wizard pages that are used in sequence, and you 
> want to use the same ActionForm for both.
> 
> Assume the form is stored in session, as you would expect in a wizard.
> 
> Now, imagine there is a firstName field on both HTML forms of both 
> wizard pages... you might argue this isn't a good wizard design, and I 
> would tend to agree, but it's something that can happen in some cases.
> 
> Now, assume a prototypical Struts app, no Struts Dialogs extensions or 
> anything...
> 
> What happens when the first page submits?  The firstName field is 
> populated in the ActionForm.  Now what about when the second form is 
> submitted?  The value of the firstName field in the ActionForm now has 
> the value from the second form submission, effectively overwriting the 
> value the user entered on the first page, so if the user were to go back 
> to the first wizard page, they would incorrectly see the data from the 
> second page in effect.  Easily to explain, but to the user it's a data 
> corruption issue.
> 
> This is the scenario I was referring to.  Does your Dialogs stuff 
> overcome that?  If so, how?  Whether it does or not, a "normal" Struts 
> app will certainly have this problem, hence my comment about making sure 
> the field names are different... in this case, it might be as simple as 
> making two fields in the ActionForm, one named firstNamePage1 and 
> firstNamePage2.
> 
> Frank
> 
> Michael Jouravlev wrote:
> 
>>On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>
>>
>>>The one thing to keep in mind if you go [one ActionForm] route is
>>>to be sure you don't have a field on one page
>>>with the same name as another.  I had one junior developer make that
>>>mistake and it drove him nuts trying to figure out what was wrong
>>>(obvious in retrospect, but one of those "tricky at the time" problems
>>>to solve).
>>
>>
>>I don't see right away how does this matter if you have separate
>>submits from a browser each time. Also would not matter if you
>>redirect between pages and don't intentionally stuff values into
>>redirected request. Redirected request comes clean, so same fields or
>>not - does not matter. This is why my two-phase request processing
>>works: POST comes with input data, form is populated, then I redirect
>>to the same action again, GET comes clean, form is not updated because
>>request contains no data.
>>
>>Forwarded request brings all input data with it, and Struts applies
>>this data to another form. Been there ;)
>>
>>Michael.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>>
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


RE: Wizard page "data corruption" (was: "Re: Form Beans")

Posted by bs...@psl.nmsu.edu.
I hope I understand what you are asking.  A couple of things come to mind about threads and Servlets.  If one uses Instance variables in Servlets then each instance of that Servlet has a unique variable and there is no data corruption.  However if one uses Class variables then each instance of a servlet shares the variables and then data corruption can occur. 

Same with formbeans and wizards.  Each formbean is unique to the specific Servlet action.  So, if one uses a single formbean for several steps in a wizard then there is no data corruption.

Am I understanding what you are asking?

--Brad. 



-----Original Message-----
From: Frank W. Zammetti [mailto:fzlists@omnytex.com]
Sent: Wed 11/16/2005 11:46 AM
To: Struts Users Mailing List
Subject: Wizard page "data corruption" (was: "Re: Form Beans")
 
Imagine you have a single ActionForm with a firstName field.  Now 
imagine you have two wizard pages that are used in sequence, and you 
want to use the same ActionForm for both.

Assume the form is stored in session, as you would expect in a wizard.

Now, imagine there is a firstName field on both HTML forms of both 
wizard pages... you might argue this isn't a good wizard design, and I 
would tend to agree, but it's something that can happen in some cases.

Now, assume a prototypical Struts app, no Struts Dialogs extensions or 
anything...

What happens when the first page submits?  The firstName field is 
populated in the ActionForm.  Now what about when the second form is 
submitted?  The value of the firstName field in the ActionForm now has 
the value from the second form submission, effectively overwriting the 
value the user entered on the first page, so if the user were to go back 
to the first wizard page, they would incorrectly see the data from the 
second page in effect.  Easily to explain, but to the user it's a data 
corruption issue.

This is the scenario I was referring to.  Does your Dialogs stuff 
overcome that?  If so, how?  Whether it does or not, a "normal" Struts 
app will certainly have this problem, hence my comment about making sure 
the field names are different... in this case, it might be as simple as 
making two fields in the ActionForm, one named firstNamePage1 and 
firstNamePage2.

Frank

Michael Jouravlev wrote:
> On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> 
>>The one thing to keep in mind if you go [one ActionForm] route is
>>to be sure you don't have a field on one page
>>with the same name as another.  I had one junior developer make that
>>mistake and it drove him nuts trying to figure out what was wrong
>>(obvious in retrospect, but one of those "tricky at the time" problems
>>to solve).
> 
> 
> I don't see right away how does this matter if you have separate
> submits from a browser each time. Also would not matter if you
> redirect between pages and don't intentionally stuff values into
> redirected request. Redirected request comes clean, so same fields or
> not - does not matter. This is why my two-phase request processing
> works: POST comes with input data, form is populated, then I redirect
> to the same action again, GET comes clean, form is not updated because
> request contains no data.
> 
> Forwarded request brings all input data with it, and Struts applies
> this data to another form. Been there ;)
> 
> Michael.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Wizard page "data corruption"

Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
Michael Jouravlev wrote:
> Then you display page 2, it loads firstName from
> ActionForm and displays it. If you change the name and submit page 2,
> it stores changed name back in ActionForm. If you go back to page 1
> and the page is not cached, it will be reloaded from server with
> updated firstName. Seems quite normal to me ;-) If pages are cachable,
> then page 1 would show stale data. But I do not use cachable pages.

That's a fair point, I didn't think of it that way.  I guess it comes 
down more to the wizard design... if the firstName field *is* meant to 
be the same, as you describe, then there's no problem.  It's when it's 
intended to be two different things that just happen to be the same name 
that there's a problem.

Now I have to go look back at the issue my colleague experienced because 
now I'm not sure what happened there... as I recall, the second page DID 
NOT show the data entered on the first, and the problem *was* corrected 
by having two different field names, but now I'm thinking something else 
was going on there.

> In this wizard http://www.superinterface.com/strutsdialog/wizardaction.do
> the last page shows the same data that was entered on the first page.
> 
> First page has <html:text name="wizardform"
> property="signupWizard.stepSignup.name"/>
> Last page has <bean:write name="wizardform"
> property="signupWizard.stepSignup.name"/>
> 
> Granted, last page just shows the name, but I could use regular text
> fields as well. I don't think that such data sharing can be regarded
> as data corruption. It is *the same* data after all.

Right, again it seems like it comes down to what the intend was... is 
the firstName field on one page meant to be the same as another.

> Michael.

Frank






> On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> 
>>Imagine you have a single ActionForm with a firstName field.  Now
>>imagine you have two wizard pages that are used in sequence, and you
>>want to use the same ActionForm for both.
>>
>>Assume the form is stored in session, as you would expect in a wizard.
>>
>>Now, imagine there is a firstName field on both HTML forms of both
>>wizard pages... you might argue this isn't a good wizard design, and I
>>would tend to agree, but it's something that can happen in some cases.
>>
>>Now, assume a prototypical Struts app, no Struts Dialogs extensions or
>>anything...
>>
>>What happens when the first page submits?  The firstName field is
>>populated in the ActionForm.  Now what about when the second form is
>>submitted?  The value of the firstName field in the ActionForm now has
>>the value from the second form submission, effectively overwriting the
>>value the user entered on the first page, so if the user were to go back
>>to the first wizard page, they would incorrectly see the data from the
>>second page in effect.  Easily to explain, but to the user it's a data
>>corruption issue.
>>
>>This is the scenario I was referring to.  Does your Dialogs stuff
>>overcome that?  If so, how?  Whether it does or not, a "normal" Struts
>>app will certainly have this problem, hence my comment about making sure
>>the field names are different... in this case, it might be as simple as
>>making two fields in the ActionForm, one named firstNamePage1 and
>>firstNamePage2.
>>
>>Frank
>>
>>Michael Jouravlev wrote:
>>
>>>On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
>>>
>>>
>>>>The one thing to keep in mind if you go [one ActionForm] route is
>>>>to be sure you don't have a field on one page
>>>>with the same name as another.  I had one junior developer make that
>>>>mistake and it drove him nuts trying to figure out what was wrong
>>>>(obvious in retrospect, but one of those "tricky at the time" problems
>>>>to solve).
>>>
>>>
>>>I don't see right away how does this matter if you have separate
>>>submits from a browser each time. Also would not matter if you
>>>redirect between pages and don't intentionally stuff values into
>>>redirected request. Redirected request comes clean, so same fields or
>>>not - does not matter. This is why my two-phase request processing
>>>works: POST comes with input data, form is populated, then I redirect
>>>to the same action again, GET comes clean, form is not updated because
>>>request contains no data.
>>>
>>>Forwarded request brings all input data with it, and Struts applies
>>>this data to another form. Been there ;)
> 
> 
> 
> 

-- 
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
AIM: fzammetti
Yahoo: fzammetti
MSN: fzammetti@hotmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Wizard page "data corruption" (was: "Re: Form Beans")

Posted by Michael Jouravlev <jm...@gmail.com>.
Oh, stupid me, you are talking about HTML FORM fields, while I was
thinking about ActionForm fields.

Returning to your case, the value does not seem "corrupted" to me. I
think it is normal that different web pages of one wizard would share
data. You display page 1, enter firstName, submit, it is stored in the
ActionForm. Then you display page 2, it loads firstName from
ActionForm and displays it. If you change the name and submit page 2,
it stores changed name back in ActionForm. If you go back to page 1
and the page is not cached, it will be reloaded from server with
updated firstName. Seems quite normal to me ;-) If pages are cachable,
then page 1 would show stale data. But I do not use cachable pages.

In this wizard http://www.superinterface.com/strutsdialog/wizardaction.do
the last page shows the same data that was entered on the first page.

First page has <html:text name="wizardform"
property="signupWizard.stepSignup.name"/>
Last page has <bean:write name="wizardform"
property="signupWizard.stepSignup.name"/>

Granted, last page just shows the name, but I could use regular text
fields as well. I don't think that such data sharing can be regarded
as data corruption. It is *the same* data after all.

Michael.

On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> Imagine you have a single ActionForm with a firstName field.  Now
> imagine you have two wizard pages that are used in sequence, and you
> want to use the same ActionForm for both.
>
> Assume the form is stored in session, as you would expect in a wizard.
>
> Now, imagine there is a firstName field on both HTML forms of both
> wizard pages... you might argue this isn't a good wizard design, and I
> would tend to agree, but it's something that can happen in some cases.
>
> Now, assume a prototypical Struts app, no Struts Dialogs extensions or
> anything...
>
> What happens when the first page submits?  The firstName field is
> populated in the ActionForm.  Now what about when the second form is
> submitted?  The value of the firstName field in the ActionForm now has
> the value from the second form submission, effectively overwriting the
> value the user entered on the first page, so if the user were to go back
> to the first wizard page, they would incorrectly see the data from the
> second page in effect.  Easily to explain, but to the user it's a data
> corruption issue.
>
> This is the scenario I was referring to.  Does your Dialogs stuff
> overcome that?  If so, how?  Whether it does or not, a "normal" Struts
> app will certainly have this problem, hence my comment about making sure
> the field names are different... in this case, it might be as simple as
> making two fields in the ActionForm, one named firstNamePage1 and
> firstNamePage2.
>
> Frank
>
> Michael Jouravlev wrote:
> > On 11/16/05, Frank W. Zammetti <fz...@omnytex.com> wrote:
> >
> >>The one thing to keep in mind if you go [one ActionForm] route is
> >>to be sure you don't have a field on one page
> >>with the same name as another.  I had one junior developer make that
> >>mistake and it drove him nuts trying to figure out what was wrong
> >>(obvious in retrospect, but one of those "tricky at the time" problems
> >>to solve).
> >
> >
> > I don't see right away how does this matter if you have separate
> > submits from a browser each time. Also would not matter if you
> > redirect between pages and don't intentionally stuff values into
> > redirected request. Redirected request comes clean, so same fields or
> > not - does not matter. This is why my two-phase request processing
> > works: POST comes with input data, form is populated, then I redirect
> > to the same action again, GET comes clean, form is not updated because
> > request contains no data.
> >
> > Forwarded request brings all input data with it, and Struts applies
> > this data to another form. Been there ;)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org