JSF设置默认值Radio Button h:selectOneRadio [英] JSF set default value Radio Button h:selectOneRadio

查看:646
本文介绍了JSF设置默认值Radio Button h:selectOneRadio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<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>

推荐答案

在后备Bean中用所需的默认值设置value.例如,如果您希望将高中"作为默认设置:

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

value = "High School";

这可以在构造函数中或在@PostConstruct方法中完成,具体取决于后备bean的范围.

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

这篇关于JSF设置默认值Radio Button h:selectOneRadio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆