tags:

views:

648

answers:

2

i have following code in jsp used with struts2 radio button i want to know which radio button is selected in my action class so can anyone give me solution on this.

code:

<div>
   <s:radio cssClass="formFieldRadio" name="selectAction" list="{'Postponed To'}"/>
   <s:radio cssClass="formFieldRadio" name="selectAction" list="{'Suspended'}"/>
   <s:radio cssClass="formFieldRadio" name="selectAction" list="{'cancelled'}"/>
</div>        

i use diffrent radio with same name so that are displayed each in new row...

A: 

I dint understand why you need all the radio buttons with the same name.. If the names are different add the getter/setter for all the radio buttons in the actions with there same names, the in action exectute() method check the values of the radio button for true or false as

if(formFieldRadio == true)

u get to know its checked or not

Vinayak.B
A: 

You are doing it wrong, you should do it like this:

<s:radio name="selectAction" list="#{1:'Postponed To', 2: 'Suspended', 3: 'cancelled'}" />

Then in your action you should expect a numeric value (in this case, 1, 2 or 3) in an selectAction variable.

make sure you have the theme="simple" attribute so you can play freely with your css.

rsilva