Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Struts Creating the Radio Button for gender

 
Jerlin Ong
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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:
Gender
<input type="radio" name="gender" checked value="Male" />
<input type="radio" name="gender" value="Female"/>

Hope this solves the problem.
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic