This section explains you creating checkbox by JSF tag. selectBooleanCheckbox tag is used to create checkbox. This tag renders an html "input" tag whose type is set to "checkbox" and "name" is set to "id". If the "value" of this component is set to "true" then a checked checkbox is rendered. This is used when we want to give an option to the user to select or deselect.
Code Description :
| <%@ taglib uri="http://java.sun.com/jsf/html"
prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <f:view> <html> <body> <h:form> <h:selectBooleanCheckbox id="checkbox" value="true" title="click it to select or deselect"/> <h:outputText value="Want to participate?"/> </h:form> </body> </html> </f:view> |
Rendered Output : In the above code value is set to true so checkbox is rendered as checked. On moving the mouse pointer to the chenkbox element a tooltip pops up that is the text written in title attribute.

Html Source Code :
| <html> <body> <form id="_id0" method="post" action="/htmltag/pages /selectBooleanCheckbox.jsf" enctype="application/x-www- form-urlencoded"> <input id="_id0:checkbox" type="checkbox" name="_id0:checkbox" checked title="click it to select or deselect" /> Want to participate? <input type="hidden" name="_id0" value="_id0" /> </form> </body> </html> |
This tag contains some attributes that are described below :
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: JSF selectBooleanCheckbox Tag
Post your Comment