struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Checkbox Bug
Date Fri, 07 Jul 2000 14:55:04 GMT

Actually, we ran into this too, and it stung.  The problem lies in how HTML
forms are transmitted.  When a checkbox is checked, the form element is
sent to the server for processing, so in struts case, the appropriate set
method is called.  Well, if the same page is submitted again, but you
uncheck a previously check boxed, the form element is NOT sent to the
server, so the corresponding set method is NOT called.  So, just using the
checkbox tag by itself is not enough.  What we did to get around this, is
to assign a hidden field for each check box.  In the set method of the
checkbox, we also set a timestamp when it was set.  The same goes for the
hidden field.  But in the hidden fields set method, we compare the
timestamps, and if the hidden fields time stamp is later, then we know the
check box was unchecked, and we set it's value to 'off'.(hidden field must
be located AFTER the check box field in the form).   This functionality
sould probably be pushed back into the custom tag, but I haven't had time
to persue it.

We also ran into a problem using rado buttons dynamically.  So we createad
a dynamic radio button tag, that allows the developer to se a pageCOntext
attribute of 'radiovalue' before you call the <struts:dynamicradio>, and it
will fill in the value for you.  Seems to do the trick.

James Birchfield
Senior Software Engineer LLC
a better way to buy, sell and rent construction equipment
5 Corporate Center
9960 Corporate Campus Drive,
Suite 2000
Louisville, KY 40223

|        |          David Geary          |
|        |          <sabreware@tri-lakeso|
|        |>           |
|        |                               |
|        |          07/07/00 10:41 AM    |
|        |          Please respond to    |
|        |          struts-user          |
|        |                               |
  |       To:     "" <>
  |       cc:                                                                            
  |       Subject:     Checkbox Bug                                                      

I posted this to struts-dev, but got no response. This is a bug, correct?


select water and coffee from this struts application:

(Embedded image moved to file: pic28091.jpg)

then submit the form, and you get this error:

(Embedded image moved to file: pic12798.jpg)

(from here on out, coffee and water will always be selected
after form submission)

deselect coffee and select tea:

(Embedded image moved to file: pic16942.jpg)


(Embedded image moved to file: pic31269.jpg)

View raw message