I'm dragging this over to the user list from a Bugzilla ticket:
     http://issues.apache.org/bugzilla/show_bug.cgi?id=34612
in which Ivan wrote (in part):

> in my form in the reset() I set the checkbox to "on".
>
> If the user turns it off, I'd expect that despite my reset's actions, a
> setCheckbox(null) would be called by struts.  But that method is never
called.
>
>Well the problem is that my reset() method decides whether the checkbox is
set
> or not based on a cookie, and then if the checkbox is unchecked - it
deleted the
> cookie.  (this is the "remember me" checkbox for logging in)
> So, if the cookie is set, there will be no way to unset it, because
"reset()" is
> dependant on the cookie, and the "checkbox" doesn't turn it off.
>
> Currently I go around this by checking if the URI ends with ".jsp" (since
the
> form has ".do" at the end), but this is a very dirty hack, isn't there a
cleaner
> way to deal with checkboxes?

I do the same thing with a bunch of checkboxes to control preferences, and a
cookie so that the page 'remembers' how the user wanted it.

I don't have a problem with the checkboxes, and the difference I see is that
you mention checking whether the request came in as .jsp or .do.  That means
you must be allowing direct access to the JSP.

If instead you force all requests to go through the Action, you can look at
the (properly reset and populated) form, look at the cookie, and decide
whether the checkbox should be checked before the page is displayed.

Not that I want to discourage you from submitting a patch. :)

-- 
Wendy Smoak


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

Reply via email to