Bob,
if you are using the 1.0 version of Struts, the reset() method
which is called before ActionForm fields are populated could be a solution
for you.
since no values are sent when a checkbox is unchecked, you can set a boolean
value
which is associated with the checkbox to false in the reset() method. when
the ActionForm
fields are populated, if a value is sent for the checkbox, your set method
for the checkbox
will set the checkbox boolean to true, else it will remain false.
a more complicated and clumsy way is possible for 0.5 Struts using hidden
fields
associated with the checkbox and javascript but the 1.0 reset() method is
far cleaner and simpler.
hope this helps...

regards,
Pat Ludwig
Silverstream Software

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]
> Sent: Monday, March 26, 2001 5:49 PM
> To: [EMAIL PROTECTED]
> Subject: Problem with "unchecking" check boxes
>
>
>
> What is the best way to uncheck a Struts checkbox? Is there a
> certain option
> I can use from within the JSP tag to account for this? What I
> have been
> doing up until now is checking for the existence of a request
> parameter in
> my Action class, and if it does not exist then manually setting the
> respective property in the ActionForm (usually to false).
> However, this is
> not preferred since it presents a serious problem when the
> class type of the
> ActionForm is not known. If the instance type of the
> ActionForm is unknown
> (i.e. it is a subclass of another ActionForm), I can't very
> well invoke a
> method to set a property to false! This problem just recently
> presented
> itself since I now have a Javabean that can be an instance of multiple
> types, linked to one ActionForm- all handled by the same save Action.
>
> What can I do???  Hopefully there is some other way to handle this,
> otherwise I will be forced to write instanceOf statements to
> determine type
> and cast the ActionForm- which I consider bad design.
>
> Thanks,
> Bob

Reply via email to