if an h:selectManyCheckbox has a attribute readonly="true", the user could not able to check or uncheck the checkbox. but able to click on it, why?
As on every other HTML input
element, the readonly
attribute only applies on the input element's value, not on the checkbox's state. This is indeed pretty unintuitive.
You can use JavaScript to let the onclick
return false
when the readonly state is true
.
onclick="return #{!bean.readonly}" readonly="#{bean.readonly}"
Please note that this unintuitive behaviour is not related to JSF, but to HTML.
精彩评论