is it a bug of CheckboxTag

2001-05-14 Thread JeanX

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)




RE: is it a bug of CheckboxTag

2001-05-14 Thread Niall Pemberton

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)
> 
> 



Re: is it a bug of CheckboxTag

2001-05-14 Thread Jim Richards


JeanX wrote:
> 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 ?

In you ActionForm reset method you need to set all the checkbox values
to false, as reset() is called before the form is populated.

That way, the only values that get sent are the ones that need to be
set to true, and the ActionForm is correctly set.



Re: is it a bug of CheckboxTag

2001-05-14 Thread JeanX

Jim Richards wrote at 2001-05-15 14:48:00,
>JeanX wrote:
>> 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 ?
>
>In you ActionForm reset method you need to set all the checkbox values
>to false, as reset() is called before the form is populated.
>
>That way, the only values that get sent are the ones that need to be
>set to true, and the ActionForm is correctly set.

So if I wanna some checkbox default true,
How can I do?


Best regards,
JeanX
pacificnet.com(GZ)




Re: is it a bug of CheckboxTag

2001-05-14 Thread Jim Richards


Set the value to true in the ActionForm reset() method.

Another thing is that you shouldn't call .jsp pages directly. They
should always be called through an Action first. From the exmaple,
the subscription page is called through (I think) editSubscription.do
to populate the form, and then forward to the .jsp page.

At the top of the .jsp page you can then put something like
(and this is from memory, so I'm not sure of the exact 
syntax)






JeanX wrote:
> 
> Jim Richards wrote at 2001-05-15 14:48:00,
> >JeanX wrote:
> >> 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 ?
> >
> >In you ActionForm reset method you need to set all the checkbox values
> >to false, as reset() is called before the form is populated.
> >
> >That way, the only values that get sent are the ones that need to be
> >set to true, and the ActionForm is correctly set.
> 
> So if I wanna some checkbox default true,
> How can I do?



Re: is it a bug of CheckboxTag

2001-05-14 Thread Jim Richards


> Another thing is that you shouldn't call .jsp pages directly. They
> should always be called through an Action first. From the exmaple,
> the subscription page is called through (I think) editSubscription.do
> to populate the form, and then forward to the .jsp page.

I should clarify this a bit. You shouldn't call .jsp pages directly
that need to be populated by the database or elsewhere. Generic
.jsp pages that just display data, content or whatever can be done
fine by calling them directly if the beans are pre-populated (eg, 
a session or application scope bean).

But if they are an editing form, eg, user details or content
editor then they should have an Action populate them first.



Re: is it a bug of CheckboxTag

2001-05-15 Thread Jeff Trent

BTW, I found that this type of logic (forward) doesn't work if you are using
templates.  I needed to resort to redirects.

- jeff

- Original Message -
From: "Jim Richards" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, May 15, 2001 1:52 AM
Subject: Re: is it a bug of CheckboxTag


>
> Set the value to true in the ActionForm reset() method.
>
> Another thing is that you shouldn't call .jsp pages directly. They
> should always be called through an Action first. From the exmaple,
> the subscription page is called through (I think) editSubscription.do
> to populate the form, and then forward to the .jsp page.
>
> At the top of the .jsp page you can then put something like
> (and this is from memory, so I'm not sure of the exact
> syntax)
>
> 
> 
> 
>
>
> JeanX wrote:
> >
> > Jim Richards wrote at 2001-05-15 14:48:00,
> > >JeanX wrote:
> > >> 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 ?
> > >
> > >In you ActionForm reset method you need to set all the checkbox values
> > >to false, as reset() is called before the form is populated.
> > >
> > >That way, the only values that get sent are the ones that need to be
> > >set to true, and the ActionForm is correctly set.
> >
> > So if I wanna some checkbox default true,
> > How can I do?
>




Re: RE: is it a bug of CheckboxTag

2001-05-14 Thread JeanX

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" %>





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)




RE: RE: is it a bug of CheckboxTag

2001-05-14 Thread Niall Pemberton

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" %>
> 
>   
>   
> 
>
> 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)
>
>




Re: Re: is it a bug of CheckboxTag

2001-05-14 Thread JeanX

Jim Richards wrote at 2001-05-15 15:52:00,
>Set the value to true in the ActionForm reset() method.
>


Hi Jim, my ActionForm are in request scope.
and I means those checkboxes are selected defaultly.

Best regards,
JeanX
pacificnet.com(GZ)