简体   繁体   中英

Struts 2 radio button value.?

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...

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM