• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

using html:radio

 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
selvi family
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic