You could have another boolean field which you'd use as an indicator of what to do:

boolean firstTime = true;

if (!firstTime)
{
contractInstructor = false;
}
else
{
firstTime = false;
}

Jim Coble wrote:

I'm using Struts 1.0.2 with Tomcat 4.1.12. I have an ActionForm with a checkbox whose default value I would like to be "on". I accomplished that by initializing the underlying bean property to true. However, I am having trouble detecting if the box is unchecked when the form is submitted.

In the Struts documentation for the HTML taglib, in the section on checkbox (<http://jakarta.apache.org/struts/struts-html.html#checkbox>), I read 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.

So, I do that; i.e.,
public void reset( ActionMapping mapping, HttpServletRequest request )
{
this.contactInstructor = false;
}
Now I can detect when the box is unchecked but it no longer defaults to "on" (which makes sense, since the reset method now says it's default value is "false").

So, my question is, is there a way to have an ActionForm checkbox default to "on" _and_ be able to detect that it has been unchecked when the form is submitted?

Thanks in advance for any assistance you can provide.
--Jim

==================================
Jim Coble
Senior Technology Specialist
Center for Instructional Technology
Email: [EMAIL PROTECTED]
Voice: 919-660-5974 Fax: 919-660-5923
Box 90198, Duke University
Durham, NC 27708-0198
==================================


--
Eddie Bush




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to