Struts radio initial values

From: Cindy Lee (dangreece_at_hotmail.com)
Date: 04/27/04


Date: Tue, 27 Apr 2004 19:16:55 GMT

I'm having problems setting my initial values. I can't change the selected
radio box value, even though I set it. It always stays at the inital value.
I can't preset it to Beta. Code parts below.

jsp file::
<%
MyActionForm mform= new MyActionForm ();
mform.setSelectedOption("Beta");
%>

<html:radio property="selectedOption" value="Alpha">Alpha</html:radio>
<html:radio property="selectedOption" value="Beta">Beta</html:radio>
<html:radio property="selectedOption" value="Charlie">Charlie</html:radio>
<html:radio property="selectedOption" value="Delta">Delta</html:radio>

The Struts ActionForm class:
public class MyActionForm extends ActionForm
{
  private String selectedOption;

  public MyActionForm()
  {
    setSelectedOption("Alpha");
  }

  public void reset(ActionMapping mapping, HttpServletRequest request)
  {
    setSelectedOption("Alpha");
  }

  public String getSelectedOption()
  {
    return this.selectedOption;
  }

  public void setSelectedOption(String selectedOption)
  {
    this.selectedOption = selectedOption;
  }
}