On Thu, 19 Apr 2001, Andrew Steady wrote:

> This is the behaviour as I understood it and it leaves no way to tell if a
> user has left a checkbox selection blank without knowing specifically that
> you were exepecting it on that page, something my current design dosen't
> enforce with other types of input (nice and dynamic).
> 

This is why the ActionForm.reset() method was invented.  The basic idea is
that your reset() method would set the boolean property associated with
the checkbox to false.  Struts calls reset() before it populates the form
bean properties -- if the checkbox was checked, the property will be set
to true; however if the checkbox wasn't checked (so there was no field
value for this parameter), the property would remain false.

This is the nature of HTML submits -- and it's one of the most frustrating
details to have to worry about.

> I may be able to extend the Form tag to include some onSubmit csjavascript
> that searches through fields and makes sure a blank string is submitted if
> it has been left unchecked. We shall see.
> 

You could use the same sort of trick to see if a zero-length String was
submitted by setting the property to null in the reset method.  If the
property is still null after the form bean properties are populated, that
means there was no field at all included in the request.

> Andy S
> 

Craig

Reply via email to