Reputation: 856
The code I am using is:
<table>
<tr>
<td>
<s:radio name="dlrMaintenanceVO.dbsVO.substitutionMethod" id="substitution" label="" list="#{'M':'Moves History'}" />
<br/>
<s:radio name="dlrMaintenanceVO.dbsVO.substitutionMethod" id="substitution" label="" list="#{'R':'Reports History'}" value="R"/>
</td>
</tr>
</table>
This should make radio button with R value as checked by default. But this thing is not happening. Any suggestions.
Upvotes: 3
Views: 12677
Reputation: 77
I'm okay with following code to set default value in radio button in struts 2.Type checked="true" you want to default in radio tag.
<table>
<tr>
<td>
<s:radio name="dlrMaintenanceVO.dbsVO.substitutionMethod" id="substitution" label="" list="#{'M':'Moves History'}" checked="true"/>
<br/>
<s:radio name="dlrMaintenanceVO.dbsVO.substitutionMethod" id="substitution" label="" list="#{'R':'Reports History'}" value="R"/>
</td>
</tr>
</table>
Upvotes: 1
Reputation: 23587
Make sure that R
should have correct value set in your action class.All you need to set the required value in your action class for R
and based on the value it will select the appropriate radio button
Upvotes: 0