开发者

why readonly attribute doesn't works for h:selectManyCheckbox?

开发者 https://www.devze.com 2023-02-26 23:21 出处:网络
开发者_Python百科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 eleme
开发者_Python百科

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消