You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Benoit Voisin <be...@ergoidp.dk> on 2003/05/28 17:47:33 UTC

ActionForm and missing fields in html:form

I have general question on which I did not find an answer in the FAQ/Google.
I seems quite a vital feature, so I believe I have missed something.
 
If the JSP does NOT contain any <html:text> or <html:hidden> tag for a field
that is referenced in the ActionForm, the ActionForm.field will be be left
untouched by Struts when the form is submitted. If this ActionForm.field's
value was modified in the reset or by a double use of the same ActionForm
object (see below), this field will contain a bad value that might end up in
the database.
 
In more details, from what I understand:
 * If I clear this field in the ActionForm.reset, the Action will use this
empty value to erase the previous value in the database.
 * If I don't clear this field in the ActionForm.reset, it will remain in
the ActionForm (if I remember well Struts creates one ActionForm instance
per session) and not be erased. But if the user opens two Netscape windows
(using the same session) editing different items, the field's value might
get exchanged : 
     -  User opens the edit window on itemA => ActionForm.unreferencedField
= "a"
     -  User opens the edit window on itemB => ActionForm.unreferencedField
= "b"
     -  User saves itemA => ActionForm.unreferencedField is left with
previous value : "b" which is saved into itemA database row... Really not
nice.
 
So my question: what's wrong in my setup ? What did I miss, or what can I do
to avoid this issue ?
 
 
Thanks in advance,
Benoit