我怎样才能有一个带有默认选中的noSelectionOption的selectOneRadio?
我有以下几点:
<p:selectOneRadio>
<f:selectItem itemLabel="none" noSelectionOption="true"/>
<f:selectItems value="#{bean.anything}"/>
</p:selectOneRadio>我想默认选择“无”吗?我该怎么做?由于没有“选定”属性,因此
发布于 2014-02-04 23:06:22
使用一个绑定到视图的受管bean字段,值为null,还有未选中的选项,值为null。
JSF部分:
<p:selectOneRadio value="#{bean.foo}">
<f:selectItem itemLabel="none" itemValue="#{null}" noSelectionOption="true"/>
<f:selectItems value="#{bean.anything}"/>
</p:selectOneRadio>托管bean代码:
@ManagedBean
@RequestScoped
public class Bean {
//its value by default will be null
private String foo;
//getters and setters...
}https://stackoverflow.com/questions/21555953
复制相似问题