The <tc:selectManyListbox/> create a list, where more than one entry could be selected. Entries are added with <tc:selectItem/> (static) or <tc:selectItems value="#{controller.list}"/> (from controller).
<tc:selectManyListbox/>
<tc:selectItem/>
<tc:selectItems value="#{controller.list}"/>
Tag Library Documentation: <tc:selectManyListbox/> | <tc:selectItem/> | <tc:selectItems/>
In this example, there is a list with three items. The second one is disabled with the itemDisabled attribute of the tag.
itemDisabled
Select an entry and press the submit-button. The text in the outputfield depends on the selection.
<tc:selectManyListbox label="List" value="#{selectManyListboxController.celestials}"> <tc:selectItem itemLabel="Sun" itemValue="The sun, "/> ... </tc:selectManyListbox> <tc:out label="Selection" value="#{selectManyListboxController.celestial}"/>
The selected deserts from the list, are shown in the <tc:out id="desertOutput" .../>. The value in the outputfield will be rerendered, after the selection in the list changed. For that, <tc:selectManyListbox label="Deserts" size="4" ...> contain a <f:ajax render="desertOutput"/> tag.
<tc:out id="desertOutput" .../>
<tc:selectManyListbox label="Deserts" size="4" ...>
<f:ajax render="desertOutput"/>
The number of rows is set to four by the size attribute. Is no size set, the height of the list depends of the number of rows. The list shows at least two rows. Values lower than two have no effect.
size
<?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.selectManyListbox} <tc:selectManyListbox>"/> <p>The <code class="language-markup"><tc:selectManyListbox/></code> create a list, where more than one entry could be selected. Entries are added with <code class="language-markup"><tc:selectItem/></code> (static) or <code class="language-markup"><tc:selectItems value="\#{controller.list}"/></code> (from controller).</p> <p>Tag Library Documentation: <tc:link label="<tc:selectManyListbox/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/selectManyListbox.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>In this example, there is a list with three items. The second one is disabled with the <code>itemDisabled</code> attribute of the <code class="language-markup"><tc:selectItem/></code> tag.</p> <tc:selectManyListbox id="s1" label="List"> <tc:selectItem itemLabel="Item1" itemValue="item1"/> <tc:selectItem itemLabel="Item2 (disabled)" itemValue="item2" itemDisabled="true"/> <tc:selectItem itemLabel="Item3" itemValue="item3"/> </tc:selectManyListbox> <tc:selectManyListbox id="s2" label="Read Only" readonly="true"> <tc:selectItem itemLabel="Item1" itemValue="item1"/> <tc:selectItem itemLabel="Item2 (disabled)" itemValue="item2" itemDisabled="true"/> <tc:selectItem itemLabel="Item3" itemValue="item3"/> </tc:selectManyListbox> <tc:selectManyListbox id="s3" label="Disabled" disabled="true"> <tc:selectItem itemLabel="Item1" itemValue="item1"/> <tc:selectItem itemLabel="Item2 (disabled)" itemValue="item2" itemDisabled="true"/> <tc:selectItem itemLabel="Item3" itemValue="item3"/> </tc:selectManyListbox> </tc:section> <tc:section label="Simple Usage"> <p>Select an entry and press the submit-button. The text in the outputfield depends on the selection.</p> <pre><code class="language-markup"><tc:selectManyListbox label="List" value="\#{selectManyListboxController.celestials}"> <tc:selectItem itemLabel="Sun" itemValue="The sun, "/> ... </tc:selectManyListbox> <tc:out label="Selection" value="\#{selectManyListboxController.celestial}"/></code></pre> <tc:selectManyListbox id="s4" label="List" value="#{selectManyListboxController.celestials}"> <tc:selectItem itemLabel="Sun" itemValue="The sun, "/> <tc:selectItem itemLabel="Moon" itemValue="the moon, "/> <tc:selectItem itemLabel="Stars" itemValue="the stars..."/> </tc:selectManyListbox> <tc:out id="o1" label="Selection" value="#{selectManyListboxController.celestial}"/> <tc:button id="b1" label="Submit"/> </tc:section> <tc:section label="Ajax" id="ajax"> <p>The selected deserts from the list, are shown in the <code class="language-markup"><tc:out id="desertOutput" .../></code>. The value in the outputfield will be rerendered, after the selection in the list changed. For that, <code class="language-markup"><tc:selectManyListbox label="Deserts" size="4" ...></code> contain a <code class="language-markup"><f:ajax render="desertOutput"/></code> tag.</p> <p>The number of rows is set to four by the <code>size</code> attribute. Is no size set, the height of the list depends of the number of rows. The list shows at least two rows. Values lower than two have no effect.</p> <tc:selectManyListbox id="s5" label="Deserts" size="4" value="#{selectManyListboxController.selectedDeserts}"> <f:selectItems value="#{selectManyListboxController.deserts}"/> <f:ajax render="desertOutput"/> </tc:selectManyListbox> <tc:out id="desertOutput" label="Selected Desets" value="#{selectManyListboxController.selectedDeserts}"/> </tc:section> </ui:composition>