Tobago Demo

Menu

Dropdown

The tag <tc:selectOneChoice/> create a dropdown box, which contain
<tc:selectItem/> for static entries or
<tc:selectItems value="#{controller.list}"/> for entries from a controller.

Tag Library Documentation: <tc:selectOneChoice/> | <tc:selectItem/> | <tc:selectItems/>

Basics

Dropdown box with hardcoded items. The second item is disabled. To disable an item, use the itemDisable attribute.

<tc:selectOneChoice label="Dropdown Box"/>

Simple Usage

Select a person. The label of the item is shown in the dropdown box. After submitting, the value of the item is shown in the output field. So, if 'Alice' is selected, the text in the output field is 'Alice Anderson'.

<tc:selectItem itemLabel="Alice" itemValue="Alice Anderson"/>

Java enum as value

Ajax

Select a planet and a moon. The list of moons depends on the selected planet. The planet-dropdownbox contain a <f:ajax render="moonbox"/>. With it, the moon-dropdownbox will be rerendered, after a value changed in planet-dropdownbox.

<tc:selectOneChoice label="Planet" value="#{selectOneChoiceController.planet}"> <f:selectItems value="#{selectOneChoiceController.planets}"/> <f:ajax render="moonbox"/> </tc:selectOneChoice> <tc:selectOneChoice id="moonbox" label="Moon"> <f:selectItems value="#{selectOneChoiceController.moons}"/> </tc:selectOneChoice>
© 2005-2023 Apache Software Foundation, Licensed under the Apache License, Version 2.0.