选中其他复选框后如何禁用复选框? [英] How to make checkboxes disabled when other checkbox is checked?

查看:186
本文介绍了选中其他复选框后如何禁用复选框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮帮我!我是新手. 我有3个组成部分.如果第一个selectBooleanCheckbox被选中,则第二个和第三个组件应被禁用.如果第一个selectBooleanCheckbox未选中,则第二个和第三个组件应该处于活动状态.

help me please! I am novice. I have 3 components of . If the first selectBooleanCheckbox checked then the second and third components should be disabled. And if the first selectBooleanCheckbox unchecked then the second and third components should be active.

<h:selectBooleanCheckbox id="checkBox_1" value="#{MyManagerBean.goldRun}"
              valueChangeListener="#{MyManagerBean.valueChangeInput}"/>
<h:selectBooleanCheckbox id="checkBox_2" value="#{MymanagerBean.useResult}" />
<h:selectBooleanCheckbox id="checkBox_3" value="#{MymanagerBean.goldSize}" />

我该怎么做?

 public void valueChangeInput(ValueChangeEvent event) {
       event.getNewValue()......
       .............................
       ..............................
 }

推荐答案

我认为您要寻找的行为只能使用ajax来完成.如果您使用的是JSF2,则内置了Ajax.您可以执行以下操作:

I think the kind of behaviour you are looking for can only be accomplished using ajax. If you are using JSF2 then ajax is built into it. You could do something like:

<h:selectBooleanCheckbox id="checkBox_1" value="#{MyManagerBean.goldRun}">
  <f:ajax event="change" render="checkBox_2 checkBox_3"/>
</h:selectBooleanCheckbox>
<h:selectBooleanCheckbox id="checkBox_2" value="#{MymanagerBean.useResult}" disabled="#{MyManagerBean.goldRun}" />
<h:selectBooleanCheckbox id="checkBox_3" value="#{MymanagerBean.goldSize}" disabled="#{MyManagerBean.goldRun}"/>

上面的代码必须采用某种形式.

The above piece of code would have to be in a form.

如果您使用的是JSF 1.2,则需要使用受ajax支持的JSF第三方库,例如 RichFaces / ICEfaces .它们具有相似的组件,并且以相同的方式工作.

If your using JSF 1.2 then you will need to use an ajax supported JSF third party library like RichFaces / ICEfaces. They have similar components that work in the same way.

这篇关于选中其他复选框后如何禁用复选框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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