JSF - h:selectBooleanCheckbox

The h:selectBooleanCheckbox tag renders an HTML input element of the type "checkbox".
<h:selectBooleanCheckbox value = "Remember Me" id = "chkRememberMe" /> 
<input id = "jsfForm1:chkRememberMe" type = "checkbox"  
   name = "jsfForm1:chkRememberMe" checked = "checked" />

id
Identifier for a component
binding
Reference to the component that can be used in a backing bean
rendered
A boolean; false suppresses rendering
styleClass
Cascading stylesheet (CSS) class name
value
A component’s value, typically a value binding
valueChangeListener
A method binding to a method that responds to value changes
converter
Converter class name
validator
Class name of a validator that’s created and attached to a component
required
A boolean; if true, requires a value to be entered in the associated field
accesskey
A key, typically combined with a system-defined metakey, that gives focus to an element
accept
Comma-separated list of content types for a form
accept-charset
Comma- or space-separated list of character encodings for a form. The accept-charset attribute is specified with the JSF HTML attribute named acceptcharset.
alt
Alternative text for nontextual elements such as images or applets
charset
Character encoding for a linked resource
coords
Coordinates for an element whose shape is a rectangle, circle, or polygon
dir
Direction for text. Valid values are ltr (left to right) and rtl (right to left).
disabled
Disabled state of an input element or button
hreflang
Base language of a resource specified with the href attribute; hreflang may only be used with href..
lang
Base language of an element’s attributes and text
maxlength
Maximum number of characters for text fields
readonly
Read-only state of an input field; text can be selected in a readonly field but not edited
rel
Relationship between the current document and a link specified with the href attribute
rev
Reverse link from the anchor specified with href to the current document. The value of the attribute is a space-separated list of link types.
rows
Number of visible rows in a text area. h:dataTable has a rows attribute, but it’s not an HTML pass-through attribute.
shape
Shape of a region. Valid values: default, rect,circle, poly. (default signifies the entire region)
style
Inline style information
tabindex
Numerical value specifying a tab index
target
The name of a frame in which a document is opened
title
A title, used for accessibility, that describes an element. Visual browsers typically create tooltips for the title’s value
type
Type of a link; for example, stylesheet
width
Width of an element
onblur
Element loses focus
onchange
Element’s value changes
onclick
Mouse button is clicked over the element
ondblclick
Mouse button is double-clicked over the element
onfocus
Element receives focus
onkeydown
Key is pressed
onkeypress
Key is pressed and subsequently released
onkeyup
Key is released
onmousedown
Mouse button is pressed over the element
onmousemove
Mouse moves over the element
onmouseout
Mouse leaves the element’s area
onmouseover
Mouse moves onto an element
onmouseup
Mouse button is released
onreset
Form is reset
onselect
Text is selected in an input field
Let us create a test JSF application to test the above tag.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns = "http://www.w3.org/1999/xhtml">

   <head>
      <title>JSF Tutorial!</title>
      <h:head>
         
         <script type = "text/javascript">
            function showCheckedValue() { 
               alert(document.getElementById('jsfForm1:chkRememberMe').checked);	 
            }
         </script>
      </h:head>
   </head>
   
   <body>
      <h2>h:selectBooleanCheckbox example</h2>
      <hr />
      
      <h:form id = "jsfForm1">
         <h3>Get value from selectBooleanCheckbox field</h3>
         <h:selectBooleanCheckbox value = "Remember Me" id = "chkRememberMe" />
         <h:commandButton value = "Show Checked" onclick = "showCheckedValue()" />
      </h:form> 
   
   </body>
</html>
Once you are ready with all the changes done, let us compile and run the application as we did in JSF - First Application chapter. If everything is fine with your application, this will produce the following result.

    37 Lectures 
     3.5 hours 

 Chaand Sheikh
 Print
 Add Notes
 Bookmark this page