Mr.Chowdary
Mr.Chowdary

Reputation: 507

All radio buttons are getting selected in struts 1.3.8

I'm using struts1.3.8. I have two radio buttons in my application.
When i try to select one and then another, Both are getting selected.
But only one should be selected at any point of time...
How to resolve it???
The sample code is...

<tr>
  <td>
    <html:radio property="allPersons" value="AllPersons"/>
    <b><bean:message key="register.allPersons"/></b>
  </td>
</tr>
<tr>
  <td>
    <html:radio property="selectedPersons" value="Selected Persons"/>
    <b><bean:message key="register.selectedPersons"/></b>
  </td>
</tr>

Upvotes: 1

Views: 1237

Answers (1)

JB Nizet
JB Nizet

Reputation: 692231

The would mutually exclude each other if they referred to the same property. Since their property is different, they can both be selected at the same time.

The point of mutually exclusive radio buttons is to choose among several values, and set a single property. The code should look like this:

<tr>
  <td>
    <html:radio property="kindOfPersonSelection" value="AllPersons"/>
    <b><bean:message key="register.allPersons"/></b>
  </td>
</tr>
<tr>
  <td>
    <html:radio property="kindOfPersonSelection" value="Selected Persons"/>
    <b><bean:message key="register.selectedPersons"/></b>
  </td>
</tr>

Upvotes: 1

Related Questions