开发者

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="form开发者_JAVA百科FieldRadio" 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜