Re: Unchecking radio buttons?

2001-05-09 Thread dhay



Thanks for that (although I don't like inserting scriptlets!).

My problem, though, is that the underlying value in my form bean is not being
displayed in the checkbox - it is set to FALSE, and yet the box appears checked.

Is this an error in Struts?  Also, am concerned that the HTML spec is not being
implemented with the checked attribute being unavailable.  Wouldn't it be easy
to add?

Laine, is the code you submitted going to be added to Struts?  I didn't get any
code in the mail by the way!

Cheers,

Dave




Spencer Smith [EMAIL PROTECTED] on 05/08/2001
05:44:30 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Re: Unchecking radio buttons?




All you really have to do is to manually set the checkbox value to false
after you display the current value:

ie:

html:checkbox property=mycheckbox /   // notice that no value is set
% MyForm.setMycheckbox(false) %// do this after you display the
above line in same JSP

where:

protected boolean mycheckbox;// mycheckbox is of type boolean (small b)

and you're in business.  If the checkbox is already checked it will still be
checked when you do a submit, because it will read the value on the page.
If you uncheck it though, it will be false which is correct too.

:-)




- Original Message -
From: Laine Donlan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 2:30 PM
Subject: RE: Unchecking radio buttons?


Here is some code that I submitted to the dev list a while back. It
might be useful as it solves the problem of the 'unchecked' checkbox
submit.  Hope it helps.

Laine

-

In order to capture the act of a user unchecking checkboxes and to
initialize the checkbox as checked/unchecked with non boolean values I
made a couple of changes to the
org.apache.struts.taglib.html.CheckboxTag.

Basically the changes consisted of:

1) Using the supplied value attribute to match against the bean property
value and generating the 'checked' attribute accordingly.  If the value
is not supplied then the previously implemented method of checking 'on',
'true', or 'yes' is performed.  So I do not think that default behavior
should be affected.

2) Added support for two new attributes - submitUnchecked (boolean) and
uncheckedValue (String).  Neither of these attributes are required and
the submitUnchecked defaults to 'false'.  If a user chooses to submit
unchecked values then two form inputs will be generated that facilitate
this function.  See below for an example:

Tag notation -
html:checkbox  name=bean property=indexedBean.property
submitUnchecked=true uncheckedValue=0 value=1/

Generated HTML -
input type=checkbox name=indexedBean.property_checkBox value=1

onclick=(this.checked?this.form['indexedBean.property'].value='1':this.
form['indexedBean.property'].value='0')
input type=hidden name=indexedBean.property value=0/ (where 0 is
the current value of the bean property)

So in this scenario the actual checkbox param in the request will be
ignored and the hidden input will be used to maintain the bean property
that the user wishes.

In the case where the user does not provide the two new attributes the
html will be generated as it is today with the exception of the
determination of the checked or unchecked mentioned above.

I could not see how this functionality was present in the current
checkbox tag without explicitly declaring two tags and adding javascript
to the checkbox tag.  Even then some scripting may be required to
differentiate between the two inputs and to initialize the hidden one.
If I missed something could someone point me in the right direction.  I
have attached the CheckboxTag.java file for review and use if anyone is
interested.

Thanks.  Comments would be appreciated.

Laine



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 5:12 PM
To: [EMAIL PROTECTED]
Subject: Re: Unchecking radio buttons?




thanks for the replies.

Yes, I need the checkbox capabilities, not radio buttons.

Question with these, though - is there an equivalent to the checked
attribute
in HTML reference speck?

I am creating checkbox with the following:  html:checkbox
property=notFolders
value=true/, and underlying value of notFolders is false.  Would
therefore
expect checkbox to appear as unchecked, and True to be submitted is
checkbox is
clicked.

Showing up as already checked, however.

Would appreciate any help...

Dave














RE: Unchecking radio buttons?

2001-05-09 Thread Laine Donlan

Sorry about that - here is the code again - there should be a zip file
attached.  I do not think that this code is going to be included in
Struts because it relies on some java script and therefore may not be
100% with all browsers, and would not work if a user disable j.s.
However it works well for us as we have control over the user
environment.


Laine


-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, May 09, 2001 1:45 PM
To: [EMAIL PROTECTED]
Subject: Re: Unchecking radio buttons?




Thanks for that (although I don't like inserting scriptlets!).

My problem, though, is that the underlying value in my form bean is not
being
displayed in the checkbox - it is set to FALSE, and yet the box appears
checked.

Is this an error in Struts?  Also, am concerned that the HTML spec is
not being
implemented with the checked attribute being unavailable.  Wouldn't it
be easy
to add?

Laine, is the code you submitted going to be added to Struts?  I didn't
get any
code in the mail by the way!

Cheers,

Dave




Spencer Smith [EMAIL PROTECTED] on
05/08/2001
05:44:30 PM

Please respond to [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Re: Unchecking radio buttons?




All you really have to do is to manually set the checkbox value to false
after you display the current value:

ie:

html:checkbox property=mycheckbox /   // notice that no value is
set
% MyForm.setMycheckbox(false) %// do this after you display
the
above line in same JSP

where:

protected boolean mycheckbox;// mycheckbox is of type boolean (small
b)

and you're in business.  If the checkbox is already checked it will
still be
checked when you do a submit, because it will read the value on the
page.
If you uncheck it though, it will be false which is correct too.

:-)




- Original Message -
From: Laine Donlan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 2:30 PM
Subject: RE: Unchecking radio buttons?


Here is some code that I submitted to the dev list a while back. It
might be useful as it solves the problem of the 'unchecked' checkbox
submit.  Hope it helps.

Laine

-

In order to capture the act of a user unchecking checkboxes and to
initialize the checkbox as checked/unchecked with non boolean values I
made a couple of changes to the
org.apache.struts.taglib.html.CheckboxTag.

Basically the changes consisted of:

1) Using the supplied value attribute to match against the bean property
value and generating the 'checked' attribute accordingly.  If the value
is not supplied then the previously implemented method of checking 'on',
'true', or 'yes' is performed.  So I do not think that default behavior
should be affected.

2) Added support for two new attributes - submitUnchecked (boolean) and
uncheckedValue (String).  Neither of these attributes are required and
the submitUnchecked defaults to 'false'.  If a user chooses to submit
unchecked values then two form inputs will be generated that facilitate
this function.  See below for an example:

Tag notation -
html:checkbox  name=bean property=indexedBean.property
submitUnchecked=true uncheckedValue=0 value=1/

Generated HTML -
input type=checkbox name=indexedBean.property_checkBox value=1

onclick=(this.checked?this.form['indexedBean.property'].value='1':this.
form['indexedBean.property'].value='0')
input type=hidden name=indexedBean.property value=0/ (where 0 is
the current value of the bean property)

So in this scenario the actual checkbox param in the request will be
ignored and the hidden input will be used to maintain the bean property
that the user wishes.

In the case where the user does not provide the two new attributes the
html will be generated as it is today with the exception of the
determination of the checked or unchecked mentioned above.

I could not see how this functionality was present in the current
checkbox tag without explicitly declaring two tags and adding javascript
to the checkbox tag.  Even then some scripting may be required to
differentiate between the two inputs and to initialize the hidden one.
If I missed something could someone point me in the right direction.  I
have attached the CheckboxTag.java file for review and use if anyone is
interested.

Thanks.  Comments would be appreciated.

Laine



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 5:12 PM
To: [EMAIL PROTECTED]
Subject: Re: Unchecking radio buttons?




thanks for the replies.

Yes, I need the checkbox capabilities, not radio buttons.

Question with these, though - is there an equivalent to the checked
attribute
in HTML reference speck?

I am creating checkbox with the following:  html:checkbox
property=notFolders
value=true/, and underlying value of notFolders is false.  Would
therefore
expect checkbox to appear as unchecked, and True to be submitted is
checkbox is
clicked

Unchecking radio buttons?

2001-05-08 Thread dhay



Hi.  I have a set of radio buttons.  However, if I check one of them, I am not
able to uncheck it!

Any ideas what I am missing?

Many thanks,

Dave






Re: Unchecking radio buttons?

2001-05-08 Thread Eric Rasmussen

Are you sure the radio buttons all have the same name?

If not, they will all be treated seperately.

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 11:42 AM
Subject: Unchecking radio buttons?




 Hi.  I have a set of radio buttons.  However, if I check one of them, I am
not
 able to uncheck it!

 Any ideas what I am missing?

 Many thanks,

 Dave








Re: Unchecking radio buttons?

2001-05-08 Thread William Jaynes

I'll presume that you mean, (1) you check a checkbox, (2) hit submit (3)
page redisplays with checkbox checked (4) you uncheck it (5) hit submit
(6) page displays with checkbox still checked.  The problem is that an
unchecked checkbox doesn't return any request parameter, so there's no
way for Struts to know to uncheck the box. You need to implement a
reset method in the ActionForm (see the javadoc). The reset method is
called before the ActionServlet populates the ActionForm from the
request parameters. So it can clear out the properties associated with
the checkbox. Then, if it is actually still checked, the ActionServlet
will repopulate.

Will


- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 2:42 PM
Subject: Unchecking radio buttons?




 Hi.  I have a set of radio buttons.  However, if I check one of them,
I am not
 able to uncheck it!

 Any ideas what I am missing?

 Many thanks,

 Dave







Re: Unchecking radio buttons?

2001-05-08 Thread Spencer Smith


I know.  Struts doesn't handle unchecked boxes very well.  In fact, it
doesn't understand them at all.

What you do is grab the current value from the DB display it, and then
manually set the value to false from either a Reset() action in your FORM or
directly from your JSP.

If you don't manually set the value to false, it will always save as True.



- Original Message -
From: Eric Rasmussen [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 12:27 PM
Subject: Re: Unchecking radio buttons?


 Are you sure the radio buttons all have the same name?

 If not, they will all be treated seperately.

 - Original Message -
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, May 08, 2001 11:42 AM
 Subject: Unchecking radio buttons?


 
 
  Hi.  I have a set of radio buttons.  However, if I check one of them, I
am
 not
  able to uncheck it!
 
  Any ideas what I am missing?
 
  Many thanks,
 
  Dave
 
 
 
 






RE: Unchecking radio buttons?

2001-05-08 Thread Moore, Amy L

typically when you click a radio button that is the default behavior one
or the other is always checked. The only reason it would not automatically
be checked when you initially view the page, is because you do not have the
'checked' attribute set within your tag. Checkboxes, unlike radio buttons,
have the ability to be checked or unchecked. Checkboxes also, as you may be
aware, have the ability to have mulitple boxes checked at once... which may
not be the functonality you are after. Hope this was helpful...

- Original Message -
From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 11:42 AM
Subject: Unchecking radio buttons?




 Hi.  I have a set of radio buttons.  However, if I check one of them, I am
not
 able to uncheck it!

 Any ideas what I am missing?

 Many thanks,

 Dave







Re: Unchecking radio buttons?

2001-05-08 Thread dhay



thanks for the replies.

Yes, I need the checkbox capabilities, not radio buttons.

Question with these, though - is there an equivalent to the checked attribute
in HTML reference speck?

I am creating checkbox with the following:  html:checkbox property=notFolders
value=true/, and underlying value of notFolders is false.  Would therefore
expect checkbox to appear as unchecked, and True to be submitted is checkbox is
clicked.

Showing up as already checked, however.

Would appreciate any help...

Dave






Re: Unchecking radio buttons?

2001-05-08 Thread Spencer Smith


All you really have to do is to manually set the checkbox value to false
after you display the current value:

ie:

html:checkbox property=mycheckbox /   // notice that no value is set
% MyForm.setMycheckbox(false) %// do this after you display the
above line in same JSP

where:

protected boolean mycheckbox;// mycheckbox is of type boolean (small b)

and you're in business.  If the checkbox is already checked it will still be
checked when you do a submit, because it will read the value on the page.
If you uncheck it though, it will be false which is correct too.

:-)




- Original Message -
From: Laine Donlan [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, May 08, 2001 2:30 PM
Subject: RE: Unchecking radio buttons?


Here is some code that I submitted to the dev list a while back. It
might be useful as it solves the problem of the 'unchecked' checkbox
submit.  Hope it helps.

Laine

-

In order to capture the act of a user unchecking checkboxes and to
initialize the checkbox as checked/unchecked with non boolean values I
made a couple of changes to the
org.apache.struts.taglib.html.CheckboxTag.

Basically the changes consisted of:

1) Using the supplied value attribute to match against the bean property
value and generating the 'checked' attribute accordingly.  If the value
is not supplied then the previously implemented method of checking 'on',
'true', or 'yes' is performed.  So I do not think that default behavior
should be affected.

2) Added support for two new attributes - submitUnchecked (boolean) and
uncheckedValue (String).  Neither of these attributes are required and
the submitUnchecked defaults to 'false'.  If a user chooses to submit
unchecked values then two form inputs will be generated that facilitate
this function.  See below for an example:

Tag notation -
html:checkbox  name=bean property=indexedBean.property
submitUnchecked=true uncheckedValue=0 value=1/

Generated HTML -
input type=checkbox name=indexedBean.property_checkBox value=1

onclick=(this.checked?this.form['indexedBean.property'].value='1':this.
form['indexedBean.property'].value='0')
input type=hidden name=indexedBean.property value=0/ (where 0 is
the current value of the bean property)

So in this scenario the actual checkbox param in the request will be
ignored and the hidden input will be used to maintain the bean property
that the user wishes.

In the case where the user does not provide the two new attributes the
html will be generated as it is today with the exception of the
determination of the checked or unchecked mentioned above.

I could not see how this functionality was present in the current
checkbox tag without explicitly declaring two tags and adding javascript
to the checkbox tag.  Even then some scripting may be required to
differentiate between the two inputs and to initialize the hidden one.
If I missed something could someone point me in the right direction.  I
have attached the CheckboxTag.java file for review and use if anyone is
interested.

Thanks.  Comments would be appreciated.

Laine



-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, May 08, 2001 5:12 PM
To: [EMAIL PROTECTED]
Subject: Re: Unchecking radio buttons?




thanks for the replies.

Yes, I need the checkbox capabilities, not radio buttons.

Question with these, though - is there an equivalent to the checked
attribute
in HTML reference speck?

I am creating checkbox with the following:  html:checkbox
property=notFolders
value=true/, and underlying value of notFolders is false.  Would
therefore
expect checkbox to appear as unchecked, and True to be submitted is
checkbox is
clicked.

Showing up as already checked, however.

Would appreciate any help...

Dave