Hi Pat,

Thanks for the suggestion... it works perfectly!!! It was a little tricky to
implement in my case because I have one or more ActionForms linked to
another ActionForm and I can't fire the reset method in all at the same
time- only when the screen is displayed for the specific ActionForm. I have
put the reset() signature in my interface now so I can invoke reset() on the
implementing ActionForms at the appropriate time. And in my main ActionForm
reset() I have the logic when to fire reset() in the linked ActionForm (I
stuck with the ServletRequest signature in the interface since this is more
general than the HttpServletReqest which is invoked by my page request):

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        if (this.getNavigate().equals("page2"))
 
lnkFermentationDetailForm.reset(mapping,(ServletRequest)request);
    }

The attached model illustrates why I have to do this (in case anyone is
working on a similar design and is interested). 

-Bob  




-----Original Message-----
From: Ludwig, Pat [mailto:[EMAIL PROTECTED]]
Sent: Monday, March 26, 2001 5:59 PM
To: [EMAIL PROTECTED]
Subject: RE: Problem with "unchecking" check boxes


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

FermentationTypes.dfClass.wmf

Reply via email to