This component lets you select more than one options from a set of available options. It renders an html "select" element of specified size with "multiple" attribute. size is used to specify how many options are to be displayed at a time. If size is not specified then it displays all the choices i.e. its default value is equal to no. of available options. If we set this size to "1" then drop down list is rendered. Instead of doing this we can use "selectManyMenu" tag of JSF. If size is specified less than the total no. of available options then scroll bar is rendered which can be used to see all the options by moving it. Options are added by the use of f:selectItem or f:selectItems.
Code Description :
<%@ 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:selectOneListbox example</title>
<style type="text/css">
<!--
body{
background-color:#fff2f2;
margin-top:30;
}
-->
</style>
</head>
<body >
<h:form><center>
<t:selectManyListbox id="smlb"
title="Press control key to select more than one banks." size="3">
<f:selectItem id="si1" itemLabel="SBI" itemValue="11" />
<f:selectItem id="si2" itemLabel="HDFC" itemValue="22" />
<f:selectItem id="si3" itemLabel="HSBC" itemValue="33" />
<f:selectItem id="si4" itemLabel="ICICI" itemValue="44" />
<f:selectItem id="si5" itemLabel="UTI" itemValue="55" />
<f:selectItem id="si6" itemLabel="PNB" itemValue="66" />
</t:selectManyListbox>
</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:selectOneListbox 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/selectManyListbox.jsf;
jsessionid=EF20BAE1F3387A9EE69C42B23DFDE6B3"
enctype="application/x-www-form-urlencoded">
<center>
<select id="_idJsp0:smlb" name="_idJsp0:smlb"
multiple="multiple" size="3"
title="Press control key to select more than one banks.">
<option value="11">SBI</option>
<option value="22">HDFC</option>
<option value="33">HSBC</option>
<option value="44">ICICI</option>
<option value="55">UTI</option>
<option value="66">PNB</option>
</select>
</center>
<input type="hidden" name="_idJsp0_SUBMIT" value="1" />
<input type="hidden" name="javax.faces.ViewState"
id="javax.faces.ViewState"
value="rO0ABXVyABNbTGphdmEubGFuZy5PYmplY3Q7kM5YnxBzKWwCAAB
4cAAAAAN0AAExcHQAHC9wYWdlcy9zZWxlY3RNYW55TGlzdGJveC5qc3A=" />
</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 selectManyListbox tag
Post your Comment