3
<h:selectOneRadio id="radio1" value="#{testBean.value}">
    <f:selectItem itemValue="High School" itemLabel="High School" />
    <f:selectItem itemValue="Bachelor's" itemLabel="Bachelor's"/>
    <f:selectItem itemValue="Master's" itemLabel="Master's"/>
    <f:selectItem itemValue="Doctorate" itemLabel="Doctorate" />
</h:selectOneRadio>
Matt Handy
  • 29,855
  • 2
  • 89
  • 112
Sathish Robert
  • 187
  • 3
  • 7
  • 12
  • Try to write questions not header. – Ankit May 05 '11 at 06:49
  • possible duplicate of [How to set default value of h:selectOneRadio button](http://stackoverflow.com/questions/2491190/how-to-set-default-value-of-hselectoneradio-button) – Harry Joy May 05 '11 at 06:49
  • @user712201: Please read the [faq](http://stackoverflow.com/faq) before asking questions. If my answer didn't solve it, try a new question following the question guidelines from the faq. ;-) – Matt Handy May 05 '11 at 08:53

1 Answers1

9

Set value in your backing bean with the desired default value. For example if you want "High School" as default:

value = "High School";

This can be done in the constructor or in an @PostConstruct method depending on the scope of your backing bean.

Matt Handy
  • 29,855
  • 2
  • 89
  • 112
  • I have no problem doing it with PostConstruct, but it fails when trying to do the same with contructor , so can you provide with some code where you are initialising it with some value fetched from database. No one has answer this so far, http://stackoverflow.com/questions/27540573/how-to-initialize-inputtextfield-with-a-value-from-database-on-runtime-without-t – Farhan stands with Palestine Dec 22 '14 at 11:12