禁用特定的< h:selectOneRadio>项目 [英] Disable specific <h:selectOneRadio> items

查看:44
本文介绍了禁用特定的< h:selectOneRadio>项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有5个单选按钮,选择其中一个然后继续操作,将我带到用户需要填写的表单.现在,在这5个表单中,我还没有完成其中两个单选按钮带给我的表格.因此,我想禁用没有准备好表单的单选按钮.

I have 5 radio buttons in my form, selecting one and proceeding takes me to a form that the user need to fill up. Now out of these 5, I have not yet finished 2 of the forms that these radio buttons take me. So I wanted to disable the radio buttons which donot have the forms ready.

现在我该如何解决:如果用户选择这些单选按钮中尚未准备好表单的一个,它会显示正在构建页面",但我想完全禁用它们,以便没人选择它.

How I solve it now: if a user selects one of these radio buttons that donot have a form ready, it says "Page under construction" but I want to disable them completely so that no one selects it.

推荐答案

如果您使用的是

If you're using f:selectItems, use the SelectItem constructor taking the disabled argument.

public class Bean {
    private List<SelectItem> selectItems;

    public Bean() {
        selectItems = new ArrayList<SelectItem>();
        selectItems.add(new SelectItem(1, "Form 1", null, false));
        selectItems.add(new SelectItem(2, "Form 2", null, false));
        selectItems.add(new SelectItem(3, "Form 3", null, false));
        selectItems.add(new SelectItem(4, "Form 4", null, true));
        selectItems.add(new SelectItem(5, "Form 5", null, true));
    }

    // getter for selectItems field ...
}

或者,如果您使用的是

Or, if you're using f:selectItem, use the itemDisabled attribute.

<f:selectItem itemValue="1" itemLabel="Form 1" itemDisabled="false" />
<f:selectItem itemValue="2" itemLabel="Form 2" itemDisabled="false" />
<f:selectItem itemValue="3" itemLabel="Form 3" itemDisabled="false" />
<f:selectItem itemValue="4" itemLabel="Form 4" itemDisabled="true" />
<f:selectItem itemValue="5" itemLabel="Form 5" itemDisabled="true" />

这篇关于禁用特定的&lt; h:selectOneRadio&gt;项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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