As it says in the following message:
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg06473.html
"The the normal behavior of an checkbox is, that it will submit the value of
the checkbox with the form if the user has selected the checkbox. If it is
not selected, the browser will not send the value of the checkbox to the
server."
So HTML is not sending back any value pairs when the checkbox is
"unchecked". Thats why you are not getting anything on your console from
your method:
> public void setIsPublic(boolean is){
> System.out.println(is);
> this.isPublic=is;
> }
If HTML does not send back request parameter pairs for unchecked checkboxes
then Struts can't do anything. It must be still set to true because your
form is in session scope - the message below says something about reset() -
I haven't had to deal with this, all my ActionForms are in request scope
http://www.mail-archive.com/struts-user@jakarta.apache.org/msg07564.html
Niall
> -----Original Message-----
> From: JeanX [mailto:[EMAIL PROTECTED]]
> Sent: 15 May 2001 05:24
> To: [EMAIL PROTECTED]
> Subject: Re: RE: is it a bug of CheckboxTag
>
>
> Hi struts-user,
>
> Thx Niall Pemberton.
> But I think that the ActionServlet set properties of form based
> request parameter pairs.
> So there may be some uncertain properties such as a boolean
> property mapped to a checkbox element.
> So I can not get the right value.
>
> ***** my TestForm Class *******
> public final class TestForm extends ActionForm{
> private boolean isPublic;
> public void setIsPublic(boolean is){
> System.out.println(is);
> this.isPublic=is;
> }
>
> public boolean getIsPublic(){
> return this.isPublic;
> }
>
> public TestForm(){
> this.isPublic=true;
>
> }
>
>
> }
>
> ******** my JSP file ********
> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
> <html:form action="/test.do" focus="name">
> <html:checkbox property="isPublic" /><br>
> <html:submit value="confirm"/>
> </html:form>
>
> If the isPublic checkbox is checked, i get 'true' message from console .
> If the isPublic checkbox is unchcked, there is nothing on console
> but the value of isPublic is still 'true'.
>
> thx any suggests.
>
> 您在 2001-05-15 04:48:00 这个时间给我的关于
> RE: is it a bug of CheckboxTag 的邮件我已经仔细阅读并欣赏了
> >This is an HTML issue.
> >
> >Lots of discussion in the archives about this:
> >
> >A recent one:
> >
> >http://www.mail-archive.com/struts-user@jakarta.apache.org/msg06473.html
> >
> >Niall
> >
> >> -----Original Message-----
> >> From: JeanX [mailto:[EMAIL PROTECTED]]
> >> Sent: 15 May 2001 04:00
> >> To: struts-user
> >> Subject: is it a bug of CheckboxTag
> >>
> >>
> >> Hi struts-user,
> >>
> >> If I uncheck a checkbox, there is no corresponding parameter pair
> >> in request.
> >> So I can not get the right status of certain form.
> >> How to resolve it ?
> >>
> >>
> >> :=)
> >> Best regards,
> >> JeanX
> >> pacificnet.com(GZ)
> >>
> >>
>
>
> Best regards,
> JeanX
> pacificnet.com(GZ)
>
>