wood burning stoves*
The moose likes Struts and the fly likes Using Struts Creating the Radio Button for gender Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Using Struts Creating the Radio Button for gender" Watch "Using Struts Creating the Radio Button for gender" New topic

Using Struts Creating the Radio Button for gender

Jerlin Ong

Joined: Nov 19, 2006
Posts: 1
When I coding for the radio button for the gender, i have conter a problem is that no getter method for property gender of bean. Besides this, I also have try it with the word like "Gender", "gen" and so on. But it also doesnt work.

Can anyone with this experiences before help me to solve the problem? Your suggestion will be appretiate.
Christian Nash
Ranch Hand

Joined: Jan 17, 2006
Posts: 107

I am assuming that you have 2 radio buttons for Gender on your jsp and you want to get the value which is selected in the Action Class.

So here goes,
First in the ActionForm class,

Then in the jsp:
<input type="radio" name="gender" checked value="Male" />
<input type="radio" name="gender" value="Female"/>

Hope this solves the problem.

- Christian
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
If you use Struts tags instead of generic html tags, the buttons will be checked or unchecked based on the value of the ActionForm property. Example:

<html:radio property="gender" value="Male" />Male
<html:radio property="gender" value="Female" />Female

Consultant, Sima Solutions
I agree. Here's the link: http://aspose.com/file-tools
subject: Using Struts Creating the Radio Button for gender
Similar Threads
radiobutton problem
dynamically checked radio button in struts1.3
Solved : Java Radiobutton problem
Retain selected content in a JSP