This section is dedicated to describe you about selectManyListbox tag. This 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"%> <f:view> <html> <body> <h:form> <h:selectManyListbox id="subscriptions" value="#{TableBean.perInfoAll}" title="select one or more options by pressing the control key" size="3"> <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:selectManyListbox> </h:form> </body> </html> </f:view> |
Rendered Output :

Html Source Code:
| <html> <body> <form id="_id0" method="post" action="/htmltag/pages/selectManyListbox.jsf" enctype="application/x-www-form-urlencoded"> <select id="_id0:subscriptions" name="_id0:subscriptions" multiple size="3" title="select one or more options by pressing the control key"> <option value="11">Thums Up</option> <option value="22">Limca</option> <option value="33">Pepsi</option> <option value="44">Sprite</option> <option value="55">Frooti</option> <option value="66">Coca-Cola</option> </select> <input type="hidden" name="_id0" value="_id0" /> </form> </body> </html> |
This tag can use some attributes that are useful in different places for different purpose. Here is the list of attributes :
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: JSF selectManyListbox Tag View All Comments
Post your Comment