问题
<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>
回答1:
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.
来源:https://stackoverflow.com/questions/5893707/jsf-set-default-value-radio-button-hselectoneradio