<h:selectBooleanCheckbox />
will render a html checkbox.
How do I add a custom attribute ‘myAttribute’ with value 6 to it so that the result will be:
<input type="checkbox" data-myAttribute="6" ... />
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There is no trivial way to achieve this. Unregistered attribtues are completely ignored. Assuming that you’re using Mojarra, your best bet is to extend Mojarra’s
CheckboxRendererwith a custom one wherein you override thegetEndTextToRender()method which writes the extra attribute. To get it to run, just register it infaces-config.xmlas a renderer for component familyjavax.faces.SelectBooleanand renderer typejavax.faces.Checkbox.An alternative is to delegate the job to some onload JavaScript.