在表单中尝试使用javascript
控制组件。但是无法使用javascript禁用或启用rich:iputNumberSpinner
组件。
以下是我的案例:
<SCRIPT language="JavaScript">
function typeChange(){
var element=document.getElementById("form2:hour");
var element2=document.getElementById("form2:check");
if(document.getElementById("form2:type").value==1){
element.disabled=true;
element2.disabled=true;
}
else{
element.disabled=false;
element2.disabled=false;
}
}
</SCRIPT>
<h:selectOneMenu id="type" onchange="typeChange()">
<f:selectItem itemValue="0" itemLabel="0" />
<f:selectItem itemValue="1" itemLabel="1" />
<f:selectItem itemValue="2" itemLabel="2" />
<f:selectItem itemValue="3" itemLabel="3" />
</h:selectOneMenu>
<rich:inputNumberSpinner id="hour" />
<h:selectBooleanCheckbox id="check" />
等待你的帮助
答案 0 :(得分:0)
似乎没有公共API,但基于inputNumberSpinner.js代码,可以像这样禁用它:
禁用:
var component = RichFaces.$('id');
if (!component.input.attr('disabled')) {
component.input.attr('disabled', true);
component.originalIncrease = component.increase;
component.increase = function() {}
component.originalDecrease = component.decrease;
component.decrease = function() {}
}
启用:
var component = RichFaces.$('id');
component.input.attr('disabled', false);
if (component.originalIncrease) {
component.increase = component.originalIncrease;
component.originalIncrease = null;
}
if (component.originalDecrease) {
component.decrease = component.originalDecrease;
component.originalDecrease = null;
}