JSF selectmanycheckbox html tag

JSF h:selectManyListbox tag is used to render a multiple select HTML input element of the type “select” with size and multiple specified.

JSF tag:

<h:selectManyListbox value="#{testBean.data}" />
<f:selectItem itemValue="1" itemLabel="Item 1" />
   <f:selectItem itemValue="2" itemLabel="Item 2" />

Rendered HTML tag:

<select name="j_idt6:j_idt8" size="2" multiple="multiple">  
   <option value="1">Item 1</option>
   <option value="2">Item 2</option>

Attributes of h:selectmanycheckbox tag.

Attribute Description
id id for the tag
binding Reference to the component used in a backing bean
rendered A boolean value; false would suppress rendering
styleClass Cascading stylesheet (CSS) class name
value value binding
valueChangeListener A method binding that responds to value changes
converter Converter class name
validator Class name of a validator attached to the component
required A boolean; if true, marks the tag as required
accesskey 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.
alt Alternative text for nontextual elements such as images
border Pixel value for an element’s border width
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;
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
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. Browsers typically create tooltips for the title’s value
type Type of a link; for example, stylesheet
width Width of an element
onblur Event handler for losing focus
onchange Event handler for value changes
onclick Event handler for Mouse button clicked over the element
ondblclick Event handler for Mouse button double-clicked
onfocus Event handler for element received focus
onkeydown Event handler for Key pressed
onkeypress Event handler for Key pressed and released
onkeyup Event handler for Key released
onmousedown Event handler for Mouse button pressed
onmousemove Event handler for mouse moved
onmouseout Event handler for mouse left
onmouseover Event handler for mouse moved onto
onmouseup Event handler for mouse button released
onreset Event handler for form reset
onselect Event handler for Text selected
immediate Process validation early in the life cycle



<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml"
		<title>JSF select many check box example.</title>
    	<h2>JSF select many check box example.</h2>
    	   <h:selectManyCheckbox value="#{test.checkBoxValues}">
    	   	<f:selectItem itemValue="MCA" itemLabel="MCA" />
    	   	<f:selectItem itemValue="CSE" itemLabel="CSE" />
    	   	<f:selectItem itemValue="IT" itemLabel="IT" />
    	   <br/> <br/>
    	   <h:commandButton value="Check CheckBox Value" 


import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
 * Managed bean.
 * @author w3spoint
public class Test {
	private String[] checkBoxValues;
	public String[] getCheckBoxValues() {
		return checkBoxValues;
	public void setCheckBoxValues(String[] checkBoxValues) {
		this.checkBoxValues = checkBoxValues;
	public String checkCheckBoxValue() {
		return "success";


<?xml version="1.0" encoding="windows-1252"?>
<faces-config version="2.0" 


<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" 


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
<html xmlns="http://www.w3.org/1999/xhtml"
		<title>JSF select many check box example.</title>
    	 <h3>Selected CheckBox values: </h3> 
    	 <ui:repeat value="#{test.checkBoxValues}" 
    	 	<h:outputText value="#{selected}"/>




JSF example9-1 Check on checkboxes. JSF example9-2 Click on Check CheckBox Value button. JSF example9-3 Download this example.

Please follow and like us:
Content Protection by DMCA.com