Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

jsf

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?

like image 794
gkp Avatar asked Dec 09 '25 23:12

gkp


1 Answers

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.

like image 135
BalusC Avatar answered Dec 12 '25 05:12

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!