Home Coding Making a Struts Radio selected

Making a Struts Radio selected

by Ben

By default, struts’s html radio tag do not allow you to make a radio to be selected as they have no “selected” property or something

<html:radio property="gender" value="F" />Male
<html:radio property="gender" value="M"/>Female

To make a radio button to be selected on load, set the value that you want to be selected in your action form reset method


public void reset(ActionMapping mapping, HttpServletRequest request) {
            super.reset(mapping, request);
            gender= "F";
      }

You may also like

Leave a Comment