struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jim Coble" <Jim.Co...@duke.edu>
Subject Struts 1.0.2 ActionForm checkbox question
Date Fri, 20 Dec 2002 16:06:29 GMT
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: jim.coble@duke.edu
Voice: 919-660-5974  Fax: 919-660-5923
Box 90198, Duke University
Durham, NC 27708-0198
==================================

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message