File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes radiobutton problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "radiobutton problem" Watch "radiobutton problem" New topic

radiobutton problem

sangeetha balasubramaniam

Joined: Nov 02, 2004
Posts: 1
hi friends,

i have two radio button,i have to select one as a default.this has to be handled using struts.please help me...........
Roel De Nijs

Joined: Jul 19, 2004
Posts: 8384

in your form:
private Collection allRadioValues;
private String radioValue = "1";
public Collection getAllRadioValues(
allRadioValues = new ArrayList();
allRadioValues.add(new LabelValueBean("1", "1"));
allRadioValues.add(new LabelValueBean("2", "2"));
public void setAllRadioValues(Collection c);
public String getRadioValue();
public void setRadioValue(String value);

in your jsp:
<c:forEach items="${nameForm.allRadioTypes}" var="radiotype" varStatus="radiotypeStatus">
<html-el:radio property="radioValue" value="${radiotype.value}"><bean:write name="radiotype" property="label" /></html-el:radio>

Hope this helps

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
san geetha
Ranch Hand

Joined: Sep 07, 2004
Posts: 44
In ur jsp:
<html:radio property="Gender" value="M"/>Male
<html:radio property="Gender" value="F"/>Female

And thatthe Gender property on the form bean should have been already set to "M" then radio button with the text Male would be checked.

Hopes this helps.
I agree. Here's the link:
subject: radiobutton problem
It's not a secret anymore!