Reposted from earlier as I think this is an important design issue and I never got any comments on it --

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.

What I have done for each my my ActionForm beans is create a method called "setDefaults()", and I call it from within the constructor as well as from within the reset() method. It is here that I set default selections for my listboxes, checkboxes, default text for the text fields, etc.

Comments?

Bryan

Reply via email to