gpt4 book ai didi

java - 选择了 noSelectionOption 的 Primefaces SelectOneRadio

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:25:51 25 4
gpt4 key购买 nike

如何让 selectOneRadio 带有默认选择的 noSelectionOption?

我有以下内容:

<p:selectOneRadio>
<f:selectItem itemLabel="none" noSelectionOption="true"/>
<f:selectItems value="#{bean.anything}"/>
</p:selectOneRadio>

我想默认选择“无”吗?我怎么做?由于

没有“选定”属性

最佳答案

使用 null 值绑定(bind)到您的 View 的托管 bean 字段,也使用 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...
}

关于java - 选择了 noSelectionOption 的 Primefaces SelectOneRadio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21555953/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com