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 Spring in Action this week in the Spring 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: 9426
    
    2

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, Certified Scrum Master
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: 9426
    
    2

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: 9426
    
    2

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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Struts 2 Radio Button Selected value