aspose file tools
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


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "radiobutton problem" Watch "radiobutton problem" New topic
Author

radiobutton problem

sangeetha balasubramaniam
Greenhorn

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
Sheriff

Joined: Jul 19, 2004
Posts: 7030
    
  28

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>
</c:forEach>

Hope this helps


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
OCAJP 7
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.
 
Consider Paul's rocket mass heater.
 
subject: radiobutton problem
 
It's not a secret anymore!