• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using html:radio

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic