Search code examples
javahtmljspradio-buttonstruts-1

to retrieve data from database and show it with tha radio buttons with radio botton containing the data value instruts 1.2


In struts 1.2, how can i highlight radio button according to my database value?I am using Form bean to set other text field values.

<tr>
    <td align = "right" nowrap>SEX:</td>
    <td align= "right" nowrap> <html:radio property="sex" value="male"/>MALE
    <html:radio property="sex" value="female"/>FEMALE</td>
</tr>

I am using form bean an following java code:stuform.setSex((String)tempmap.get("SEX")); here stuform is object of StudentForm class and tempmap contain data from select query.


Solution

  • You can use an if statement, I am using jstl if statement but you can use tag too.

    <c:if test="${myForm.sex=='female'}">
        <html:radio property="sex" value="female"/><span style="color: red;">FEMALE</span></td>
    </c:if>