This section describes you about selectOneListbox tag in detail. This is used when you have to allow the user to select only one option from the list. Actually it renders an html "select" element of any size and no "multiple" attribute. The choices that we have to display in the list are shown by f:selectItem or f:selectItems. size attribute is used to set the number of options to display at a time. If its size is not specified then it shows all the choices i.e. its default size is equal to no. of available options. If we set size attribute to less than the total no. of available choices then a scrollbar appears and the number of elements specified in the size attribute are shown. We can see other options by moving the scrollbar down and up. If size is set to "1" then drop down menu is rendered. So instead of using this strategy, its good to use "selentOneMenu" tag provided by JSF.
Code Description :
|<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>|
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<h:selectOneListbox id="sol" value="TableBean.perInfoAll" size="3" title="select one option">
<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" />
Rendered Output :
Html Source Code:
This tag contains some attributes that can be used for different purposes. These attributes are summarized 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.