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 checkboxes 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.
It also provides an attribute layoutwidth. This
attribute takes integer value that is used to specify the no. of
checkbox rows if layout is lineDirection and no. of columns if layout is
pageDirection.
Code Description : In this code, the index attribute is to identify the
item to select for display.
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t"%> <f:view>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>t:selectManyCheckbox example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body >
<h:form><center>
<t:selectManyCheckbox id="smc" layoutWidth="3"
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" />
</t:selectManyCheckbox><br>
</center></h:form>
</body>
</html>
</f:view>
|
Rendered Output :

Html Source Code :
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<title>t:selectManyCheckbox example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body >
<form id="_idJsp0" name="_idJsp0" method="post"
action="/tomahawk_tags/pages/selectManyCheckbox.jsf"
enctype="application/x-www-form-urlencoded"><center>
<table id="_idJsp0:smc">
<tr><td><label>
<input type="checkbox" name="_idJsp0:smc" value="11"
title="this is 'selectManyCheckbox' demo" />
 Thums Up
</label></td><td><label>
<input type="checkbox" name="_idJsp0:smc" value="44"
title="this is 'selectManyCheckbox' demo" />
 Sprite</label></td></tr><tr><td><label>
<input type="checkbox" name="_idJsp0:smc" value="22"
title="this is 'selectManyCheckbox' demo" />
 Limca</label></td><td><label>
<input type="checkbox" name="_idJsp0:smc" value="55"
title="this is 'selectManyCheckbox' demo" />
 Frooti</label></td></tr><tr><td><label>
<input type="checkbox" name="_idJsp0:smc" value="33"
title="this is 'selectManyCheckbox' demo" />
 Pepsi</label></td><td><label>
<input type="checkbox" name="_idJsp0:smc" value="66"
title="this is 'selectManyCheckbox' demo" />
 Coca-Cola</label></td></tr></table><br>
</center><input type="hidden" name="_idJsp0_SUBMIT"
value="1" />
<input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState" value="rO0ABXVyABNbTGphdmE
ubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB4cAAAAAN0AAE1cHQAHS9w
YWdlcy9zZWxlY3RNYW55Q2hlY2tib3guanNw" /></form>
<!-- MYFACES JAVASCRIPT -->
</body> </html> |
This tag contains attributes given 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: Tomahawk selectManyCheckbox tag
Post your Comment