Originally posted by Scott Updike:
1) How do I default a value to one of the two possible values (ie, no)?
2) The value of the radio button (yes or no) is written to a database. How do I bring that value back and "pre-populate" the radio button based on the value stored in the database. (ie, if No is in the database, how do I populate the radio button so that "No" is selected in the resulting JSP page?
The <html:radio> tag automatically shows the button as checked if it matches the value of the property specified in your ActionForm. I'd suggest that you create a property of type boolean in your ActionForm. If you want the default value to be false, or "no", you don't have to do anything, since the default value of a boolean is always false. If you want the default value to be true, the best way to do it is to override the reset() method of your ActionForm, and set the value to true in that method.
You can then save the value in the database as a boolean, or translate it to a VARCHAR "Y" or "N" as you prefer. When you retrieve it from the database, simply set the appropriate value for the property in the ActionForm, and the correct radio button will be selected when the form is displayed.
Here's what your JSP would look like:
Here's what your ActionForm would look like: