John Topley's KnowledgebasePre-Selecting A Radio Button Using The Struts Radio TagThursday, 13 November 2003The Jakarta Struts <html:radio> tag is used to display radio buttons on an HTML form. It's possible to pre-select one of the buttons by specifying a default value for the property on the ActionForm associated with the radio button. The property mutator (setter method) must be called from the constructor and the reset method. Note that it shouldn't be called from the reset method if using a form bean with session scope (as you might for a multi–page workflow) because the selections will be reset for each page. The code given below displays four radio buttons with the labels “Alpha”, “Beta”, “Charlie” and “Delta” with the “Alpha” radio button pre-selected. Download 0030.txt
<html:radio property="selectedOption" value="Alpha">Alpha</html:radio>
public class MyActionForm extends ActionForm |
![]() |

