Developing Web 2.0 applications
with JavaServerFaces
and Dreamweaver
>> Just Became Easier
Documentation
Search
  1. Introduction
  2. Getting Started
  3. Developing Web Sites
  4. Using Components
  5. Internationalization
  6. Code View Support
  7. Design View Support
  8. Keyboard Shortcuts
  9. Tag Object Toolbars
  10. JSF Server Behaviors
  11. Property Inspectors
  12. JSF Tag Reference
JSF Core Tag Library
  f:actionListener
  f:ajax
  f:attribute
  f:convertDateTime
  f:convertNumber
  f:converter
  f:event
  f:facet
  f:loadBundle
  f:metadata
  f:param
  f:phaseListener
  f:selectItem
Selected f:selectItems
  f:setPropertyActionListener
  f:subview
  f:validateBean
  f:validateDoubleRange
  f:validateLength
  f:validateLongRange
  f:validateRegex
  f:validateRequired
  f:validator
  f:valueChangeListener
  f:verbatim
  f:view
  f:viewParam
If you like this documentation, please take a look at my book:

12. JSF Core Tag Reference

Documentation > JSF > JSF Tag Reference > JSF Core Tag Library > f:selectItems

f:selectItems

The SelectItems tag adds a child UISelectItems component to the component associated with enclosing tag. You can use this tag to set a list of objects in your domain model as the options for a select component. The body content of this tag must be empty.

JSF Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" 
      xmlns:f="http://java.sun.com/jsf/core" 
      xmlns:h="http://java.sun.com/jsf/html">
<h:head />
<body>
<h:form id="form">
	<h:selectOneMenu value="#{customerController.customer.homeAddress.country}" 
	                 converter="countryConverter" id="countryList">
		<f:selectItems value="#{countryController.countries}" var="country" 
		               itemLabel="#{country.name}" itemValue="#{country}" />
	</h:selectOneMenu>
	<h:commandButton value="Submit" id="button1" />
</h:form>
</body>
</html>
This example was formatted by JSFToolbox for Dreamweaver.

Rendered Output

Rendered f:selectItems tag

HTML Output

<form id="form" name="form" method="post" action="..." enctype="application/x-www-form-urlencoded">
	<select id="form:countryList" name="form:countryList" size="1">
		<option value="USA">USA</option>
		<option value="Canada">Canada</option>
		<option value="etc.">etc.</option>
	</select>
	<input id="form:button1" type="submit" name="form:button1" value="Submit" />
</form>

Tag Attributes

binding Expression
 
The value-binding expression linking this component tag to a backing bean property.
id Text
 
The unique identifier value for this component. The value must be unique within the closest naming container.
itemDescription Text
 
evaluates to a String that will serve as the description to be shown for the item.
itemDisabled Boolean
 
evaluates to a boolean that will determine if the item value is selectable or not.
itemLabel Text
 
evaluates to a String that will serve as the label to be shown for the item.
itemLabelEscaped Boolean
 
evaluates to a boolean that will determine if the rendered markup for the item receives normal JSF HTML escaping or not.
itemValue Text
 
evaluates to a Collection, array, or Map from which the items to be shown will be rendered.
noSelectionValue Text
 
Is either an EL expression pointing to the element in the value collection whose value should be marked as a no selection item, or a literal string that exactly matches the value of the item in the collection that must be marked as the no selection item. If the user selects such an item and the field is marked as required, then it will not pass validation.
value Text
 
The value attribute sets the current value for this component.
var Text
 
The var attribute sets the name of a request-scope attribute exposing the data for each iteration over the rows in the underlying data model for this table.