在< h:selectOneRadio>中禁用用户选择 [英] Disable User Selection in <h:selectOneRadio>
本文介绍了在< h:selectOneRadio>中禁用用户选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试禁用标签中的用户选择.
I am trying to disable user selection in tag.
<h:selectOneRadio id="wildcard" value="#{NewService.isWildCard}" label="#{msg.org_IsWildCard}" readonly="true" layout="lineDirection">
<f:selectItem id="yes" itemLabel="YES" itemValue="1" />
<f:selectItem id="no" itemLabel="NO" itemValue="0" />
</h:selectOneRadio>
但是,在我的GUI上,我仍然可以选择单选按钮值. 请告诉我代码中有什么问题..BackingBean代码也很简单..我只是在backingBean中传递0或1 ...
However on my GUI I am still able to select radio button value. Please tell me what is wrong in the code..Also the BackingBean code is pretty simple..I am just passing 0 or 1 in backingBean...
请指导我如何禁用
推荐答案
这确实是JSF生成的HTML <input type="radio">
元素的不直观行为.对于您的问题,基本上有2种解决方案:
This is indeed unintuitive behaviour of the JSF-generated HTML <input type="radio">
element. There are basically 2 solutions to your problem:
-
使用
disabled="true"
代替readonly="true"
:
<h:selectOneRadio disabled="true">
添加一个返回false的onclick处理程序:
Add an onclick handler which returns false:
<h:selectOneRadio onclick="return false;">
这篇关于在< h:selectOneRadio>中禁用用户选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文