aspose file tools*
The moose likes Struts and the fly likes Struts 2 Radio Button Selected value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts 2 Radio Button Selected value" Watch "Struts 2 Radio Button Selected value" New topic
Author

Struts 2 Radio Button Selected value

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Guys,

I have the following struts tag to iterate the options and display them as a radio button:



How do I get the value of the radio button that the user selected in my action class? Is there a Struts way of doing that? Or should I use the HttpServletRequest#getParameter methods?


SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

Hi Joe,

You can simply display the value of radio button with


Regards
Jatan
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

But I would like to have that value in my action class. I'm using jQuery ajax function to do the form submit. Here is the jQuery function:



As you can see, I'm serializing the data as per the documentation from jQuery. But I see nothing in my action class.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

Found out the issue. The div element that contains the radio buttons was not inside the s:form tag. Once I had them inside, it started working!
 
Don't get me started about those stupid light bulbs.
 
subject: Struts 2 Radio Button Selected value
 
Similar Threads
Dynamic radio button problem
How to make Struts radio button selected by default
s:radio and display tag
Struts 2 checkboxlist error - list key could not be resolved
Struts 2 Iterate a List of Objects