The underlying problem is that the HTML spec tells the browsers to not
submit a checkbox if it is not checked. (Or any other blank control for
that matter.) There's not a lot we can do about that =:o(
What happens with a box that starts out checked, is that when it is
unchecked, nothing is submitted. If the box represents a persistent
state, it just stays checked, since nothing turned it off.
Some times a radio button is a better way to go, since something will
always be submitted.
The reset method grew out of a need to set the checkboxes to a known
state, to get around this quirk of HTML.
The alternative is to scan the request for the missing checkboxes, and
set them as expected if they are missing.
-- Ted Husted, Husted dot Com, Fairport NY US
-- Developing Java Web Applications with Struts
-- Tel: +1 585 737-3463
-- Web: http://husted.com/about/services
Chris Means wrote:
> I'm having a problem with setting check box states on my form.
> I have a checkbox on my form, it's supposed to be "checked" if muting is
> occurring, and not checked otherwise.
> The user just needs to click the checkbox to change/toggle the state.
> However, I only seem to get an Action setting if the checkbox is not
> checked...any ideas what I'm doing wrong? Shouldn't the property be set
> regardless of the state of the object?
> My JSP:
> onclick="this.form.submit ()" />Mute
> My FormBean:
> public void setMute (boolean newMute)
> mute = newMute ;
> action = "mute" ;
> My ActionForm:
> ControlPanelForm cp = (ControlPanelForm) form ;
> String action = cp.getAction () ;
> System.out.println ("Action: " + action) ;
> if ("mute".equals (action))
> api.mute () ;
> status.refresh () ;
> cp.setMute (status.isMuted ()) ;
> return (mapping.findForward ("success"));
> To unsubscribe, e-mail:
> For additional commands, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail: