The value is what is submitted for the checkbox if the checkbox is a checked
checkbox.

For example: if your form has a string property named foo, and your
checkbox's value is "bob", then if you check the checkbox and submit,
form.getFoo() will return "bob".

If you dont check the checkbox and submit, NOTHING is submitted (not a null,
not an empty string, nothing!) - so setFoo() is NOT called and if its value
was "bob" it will STAY bob. Note that if you are using a request scoped
actionForm you probably wont notice this as a problem as you will get a new
form instance each submit anyway.

Of course if you set foo to "bob" in your reset, then the checkbox will
display as checked, BUT if you uncheck it and submit, nothing is submitted,
so the value will still be "bob" in the form...

The place to preset values for your checkbox is in the action you go through
before going to the view, and your reset method should should set the value
for foo to "unbob" or false (if you use a boolean property) or "false" or
whatever so that unchecked boxes can be detected by your code.

(For various reasons its recommended to preceed all views with an action -
even if its a no-op action - instead of linking directly to the jsp)

-----Original Message-----
From: Abhinav (Cognizant) [mailto:[EMAIL PROTECTED]
Sent: Thursday, 29 May 2003 20:00
To: Struts Users Mailing List
Subject: Checkbox ????



The documentation says : You must set the boolean property to false in the
reset method of ActionForm.
What does it mean.

Browser will only submit those checkboxes which are checked.
And what is the significance of 'value' attribute of the checkbox thus
generated
given that it  has one of {"on", "off"}.

I have to show a checkbox prechecked when the page loads. How can I do that.
The checkbox value has no influence on it.

Thanx.



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

Reply via email to