I have a radiobutton list and would like to disable some items according to the outcome of a backing bean method.
<h:selectOneRadio value="#{managedBean.selectedItem}">
<f:selectItems value="#{managedBean.selectItems}"
var="x"
itemDisabled="#{managedBean.checkIncompatible(x)}" />
</h:selectOneRadio>
Is this the right way to do it? Meaning, will this code call checkIncompatible(x)
for each x
from the selectItems
list and set that item as enabled/disabled or just once and that's that?
I only managed to get all buttons to be either enabled or disabled and my suspicion is that the method only gets called once. Or that the rest of my code is not as perfect as I like to believe. And that would take a much longer question to fix.
I can't reproduce your problem on Mojarra 2.1.4 with the following view:
and the following bean:
The above example correctly disables item
two
.So, your problem is caused elsewhere, perhaps by a bug in
checkUncompatible()
method. A breakpoint on the method teaches me that it's definitely called for each item.