OK. Now it works, sort of. On the form I am processing there are
2 sets of checkboxes. One set is simply made using html:multibox.
The other set is inserted by a single custom tag that I wrote.
I followed your suggestion (but had to dig for details) and created
the following:
public class SeriesPropsForm extends DynaActionForm
{
public void reset
(
ActionMapping mapping,
HttpServletRequest request
)
{
initialize(mapping);
}
}
That helps. Both sets of checkboxes require at least one item
to be checked. I have validation code in the Action that checks
for this, sets errors and then forwards back to the form if any errors
are found. When I test and deselect all checkboxes in both sets
my Action finds the problems, saves errors and forwards back to
the form. When the form repaints, the set built with multibox comes
up as I would expect: with nothing checked. The other set of checkboxes
comes up as it was just before I deselected and submitted. I don't
understand why they work differently. Any ideas?
Dean Hoover
Wendy Smoak wrote:
From: Dean A. Hoover [mailto:[EMAIL PROTECTED]
I don't quite understand how DynaActionForm
gets populated when a form is submitted. The
form I have gets processed exactly as I expect,
except for a group of checkboxes
(This is a FAQ-- the answer is in the list archives multiple times.)
Un-checked checkboxes are not successful form elements and will not be
present in the request.
You need to clear all of the checkboxes prior to Struts' populating the
form from the request. There are several ways to do this, the most
popular of which is to override the 'reset' method and set the checkbox
properties to false. With dynamic forms, there's an 'initialize' method
that will initialize the form based on the info in struts-config.xml.
You can call that from 'reset'. If you are using DynaActionForm
directly, you'll need to subclass it to provide the 'reset' method.
If you don't do this, as you've noticed, it's impossible to ever
un-check a checkbox on your form.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]