It's not a secret anymore!*
The moose likes Struts and the fly likes using html:radio Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "using html:radio" Watch "using html:radio" New topic
Author

using html:radio

selvi family
Ranch Hand

Joined: Nov 26, 2004
Posts: 39
How to make the radio button selected by default on page load

I am fetching some records from DB and storing that in bean and populating radio button values using
<jsp:useBean id="sel" class="myTest.struts.bean.ViewForm" />
<html:radio property="select" value="<%= bean.getName()%>" ></html:radio>
I am putting the value of first name in an hidded variable called 'val'

i referes the index of first record.

this is my Form class


import org.apache.struts.action.*;

public class ViewForm {

private String select="selvi";


}
public void setSelect(String s)
{

this.select=s;

}
public String getSelect()
{
return select;
}

}
when I am loading the JSP radio button corresponds to first record "selvi" is not getting selected.





pls help me to solve this..
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
A common mistake with the <html:radio> tag is to misunderstand the "value" attribute. With this tag, the "value" attribute refers to the value that will be passed back from the form if the button is selected.

Check the html rendered from your jsp by using your browser's
"view source" function. If the html for this button does not read value="selvi", then you know you haven't set up the value attribute properly.

If it does read value="selvi", then the problem is likely to be with the form bean not being populated correctly.

Here is a link to the documentation on the <html:radio> tag.

http://struts.apache.org/userGuide/struts-html.html#radio
[ July 25, 2005: Message edited by: Merrill Higginson ]

Merrill
Consultant, Sima Solutions
selvi family
Ranch Hand

Joined: Nov 26, 2004
Posts: 39
I jus checked the View source of the page .it reads the value="selvi" but still the radio button is not getting selected. pls get me some solution
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using html:radio
 
Similar Threads
How to make dynamic radio button checked
html:radio
Arraylist in JSP with Html radio
preselect a radio button
how to by dfault get the radio button be selected