<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>
Run Code Online (Sandbox Code Playgroud)
value
在您的支持bean中设置所需的默认值.例如,如果您希望"高中"作为默认值:
value = "High School";
Run Code Online (Sandbox Code Playgroud)
这可以在构造函数中完成,也可以在@PostConstruct方法中完成,具体取决于辅助bean的范围.