The <tc:selectOneListbox/> create a list of entries, where only one entry can be selected. Items can be added with <tc:selectItem/> or <tc:selectItems/>.
<tc:selectOneListbox/>
<tc:selectItem/>
<tc:selectItems/>
Tag Library Documentation: <tc:selectOneListbox/> | <tc:selectItem/> | <tc:selectItems/>
If the number of rows is not set, die height of the list depends on the number of entries. The number of rows can be set by the size attribute. A list has at least two rows, therefor values less than two have no effect.
size
<tc:selectOneListbox label="List" size="3"> <tc:selectItem itemLabel="Alpha"/> ... </tc:selectOneListbox>
Select a river in the list. After pressing the submit-button, the length of the river is shown in the outputfield.
Items are added with <tc:selectItem itemLabel="Nile" itemValue="6853 km"/>.
<tc:selectItem itemLabel="Nile" itemValue="6853 km"/>
Select a mountain in the list. The height will be displayed by <tc:out id="selectedMountain" .../>. The <tc:selectOneListbox/> contain a <f:ajax render="selectedMountain"/>, which rerender the outputfield.
<tc:out id="selectedMountain" .../>
<f:ajax render="selectedMountain"/>
<?xml version="1.0" encoding="UTF-8"?> <!-- * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <ui:composition template="/main.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:tc="http://myfaces.apache.org/tobago/component" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core"> <ui:param name="title" value="#{demoBundle.selectOneListbox} <tc:selectOneListbox>"/> <p>The <code class="language-markup"><tc:selectOneListbox/></code> create a list of entries, where only one entry can be selected. Items can be added with <code class="language-markup"><tc:selectItem/></code> or <code class="language-markup"><tc:selectItems/></code>.</p> <p>Tag Library Documentation: <tc:link label="<tc:selectOneListbox/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/selectOneListbox.html"/> | <tc:link label="<tc:selectItem/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/selectItem.html"/> | <tc:link label="<tc:selectItems/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/selectItems.html"/></p> <tc:section label="Basics"> <p>If the number of rows is not set, die height of the list depends on the number of entries. The number of rows can be set by the <code>size</code> attribute. A list has at least two rows, therefor values less than two have no effect.</p> <pre><code class="language-markup"><tc:selectOneListbox label="List" size="3"> <tc:selectItem itemLabel="Alpha"/> ... </tc:selectOneListbox></code></pre> <tc:selectOneListbox id="s1" label="List" size="3"> <tc:selectItem itemLabel="Alpha"/> <tc:selectItem itemLabel="Beta"/> <tc:selectItem itemLabel="Gamma"/> <tc:selectItem itemLabel="Delta"/> </tc:selectOneListbox> <tc:selectOneListbox id="s2" label="Read Only" readonly="true" size="3"> <tc:selectItem itemLabel="Alpha"/> <tc:selectItem itemLabel="Beta"/> <tc:selectItem itemLabel="Gamma"/> <tc:selectItem itemLabel="Delta"/> </tc:selectOneListbox> <tc:selectOneListbox id="s3" label="Disabled" disabled="true" size="3"> <tc:selectItem itemLabel="Alpha"/> <tc:selectItem itemLabel="Beta"/> <tc:selectItem itemLabel="Gamma"/> <tc:selectItem itemLabel="Delta"/> </tc:selectOneListbox> </tc:section> <tc:section label="Simple Usage"> <p>Select a river in the list. After pressing the submit-button, the length of the river is shown in the outputfield.</p> <p>Items are added with <code class="language-markup"><tc:selectItem itemLabel="Nile" itemValue="6853 km"/></code>.</p> <tc:selectOneListbox id="riverList" label="River" value="#{selectOneListboxController.river}"> <tc:selectItem itemLabel="Nile" itemValue="6853 km"/> <tc:selectItem itemLabel="Amazon" itemValue="6437 km"/> <tc:selectItem itemLabel="Yangtze" itemValue="6300 km"/> <tc:selectItem itemLabel="Yellow River" itemValue="5464 km"/> <tc:selectItem itemLabel="Paraná River" itemValue="4880 km"/> </tc:selectOneListbox> <tc:out id="riverOutput" label="Length" value="#{selectOneListboxController.river}"/> <tc:button id="riverSubmit" label="Submit"/> </tc:section> <tc:section label="Ajax"> <p>Select a mountain in the list. The height will be displayed by <code class="language-markup"><tc:out id="selectedMountain" .../></code>. The <code class="language-markup"><tc:selectOneListbox/></code> contain a <code class="language-markup"><f:ajax render="selectedMountain"/></code>, which rerender the outputfield.</p> <tc:selectOneListbox id="mountainList" label="Mountains" value="#{selectOneListboxController.mountain}"> <tc:selectItems value="#{selectOneListboxController.mountains}" var="mountain" itemLabel="#{mountain.label}" itemValue="#{mountain.value}"/> <f:ajax render="selectedMountain"/> </tc:selectOneListbox> <tc:out id="selectedMountain" label="Height" value="#{selectOneListboxController.mountain}"/> </tc:section> </ui:composition>