You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bryan Field-Elliot <br...@netmeme.org> on 2001/03/09 19:28:33 UTC
Observations on ActionForms, reset(), tags
I am working wth ActionForms, one of which contains some list boxes and
some checkboxes. In building my ActionForm class, I am noticing in the
docs (under "Form Construction Tags") warnings like the following:
*WARNING*: In order to correctly recognize unchecked checkboxes, the
|ActionForm| bean associated with this form must include a statement
setting the corresponding boolean property to |false| in the |reset()|
method.
*WARNING*: In order to correctly recognize cases where no selection at
all is made, the |ActionForm| bean associated with this form must
include a statement resetting the scalar property to a default value (if
|multiple| is not set), or the array property to zero length (if
|multiple| is set) in the |reset()| method.
So, in my reset() method, I am putting default values for these
properties, as recommended.
However, I am noticing that in the "first pass" of loading a JSP page
(before any Action has occured), my ActionForm bean's reset() method is
not being called; only it's constructor is being called. So, the logic I
put into the "reset" method, I copied into my default constructor as well.
It seems to me that one of the following should happen:
1. The default constructor should call the reset() method.
2. The docs should be updated to indicate that, if you are going to put
default values in your ActionForm, you better set them from your default
constructor as well as from your reset() method.
Comments?
Bryan