This section is to describe you selectManyCheckbox tag
of JSF. It is used to provide the user to select many items from a list of
options. The user can select one or more options. This supports two layouts "lineDirection"
and "pageDirection".layout determines whether the chenkboxes are laid
out horizontally or vertically. lineDirection is the default
layout. lineDirection sets the checkboxes in the horizontal direction of the
page and pageDirection is used to set the checkboxes in vertical direction of
the page. f:selectItem or f:selectItems are used to provide a list
of available options. selectManyCheckbox renders these options in a table
where each option is set to one cell. Each cell contains the checkbox and label
of the option. The value attribute of this tag must be value binding expression.
This value can be bound to data type of java like primitive array, object array,
List.
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:outputText value="Click one or more options below :"/> <h:selectManyCheckbox id="smc" value="#{TableBean.perInfoAll}" border="1" disabled="false" title="this is 'selectManyCheckbox' demo" layout="lineDirection"> <f:selectItem id="si1" itemLabel="Thums Up" itemValue="11" /> <f:selectItem id="si2" itemLabel="Limca" itemValue="22" /> <f:selectItem id="si3" itemLabel="Pepsi" itemValue="33" /> <f:selectItem id="si4" itemLabel="Sprite" itemValue="44" /> <f:selectItem id="si5" itemLabel="Frooti" itemValue="55" /> <f:selectItem id="si6" itemLabel="Coca-Cola" itemValue="66" /> </h:selectManyCheckbox><br> </h:form> </body> </html> </f:view> |
Rendered Output :

Html Source Code:
| <html> <body> <form id="_id0" method="post" action="/htmltag/pages/selectManyCheckbox.jsf" enctype="application/x-www-form-urlencoded"> Click one or more options below : <table border="1" id="_id0:smc"><tr><td> <label><input name="_id0:smc" value="11" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Thums Up</input></label></td> <td> <label><input name="_id0:smc" value="22" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Limca</input></label></td> <td> <label><input name="_id0:smc" value="33" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Pepsi</input></label></td> <td> <label><input name="_id0:smc" value="44" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Sprite</input></label></td> <td> <label><input name="_id0:smc" value="55" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Frooti</input></label></td> <td> <label><input name="_id0:smc" value="66" type="checkbox" border="1" title= "this is 'selectManyCheckbox' demo"> Coca-Cola</input></label> </td> </tr> </table><br> <input type="hidden" name="_id0" value="_id0" /></form> </body> </html> |
This tag is comprised of many attributes that are summarized below :
|
Recommend the tutorial |
Ask Questions? Discuss: JSF selectManyCheckbox Tag View All Comments
Post your Comment