{
throw new NoSuchElementException();
}
if (_nextItem != null)
{
SelectItem value = _nextItem;
_nextItem = null;
return value;
}
if (_nestedItems != null)
{
Object item = _nestedItems.next();
if (!(item instanceof SelectItem))
{
// check new params of SelectItems (since 2.0): itemValue, itemLabel, itemDescription,...
// Note that according to the spec UISelectItems does not provide Getter and Setter
// methods for this values, so we have to use the attribute map
Map<String, Object> attributeMap = _currentUISelectItems.getAttributes();
// write the current item into the request map under the key listed in var, if available
boolean wroteRequestMapVarValue = false;
Object oldRequestMapVarValue = null;
final String var = (String) attributeMap.get(VAR_ATTR);
if(var != null && !"".equals(var))
{
// save the current value of the key listed in var from the request map
oldRequestMapVarValue = _facesContext.getExternalContext().getRequestMap().put(var, item);
wroteRequestMapVarValue = true;
}
// check the itemValue attribute
Object itemValue = attributeMap.get(ITEM_VALUE_ATTR);
if (itemValue == null)
{
// the itemValue attribute was not provided
// --> use the current item as the itemValue
itemValue = item;
}
// Spec: When iterating over the select items, toString()
// must be called on the string rendered attribute values
Object itemLabel = attributeMap.get(ITEM_LABEL_ATTR);
if (itemLabel == null)
{
itemLabel = itemValue.toString();
}
else
{
itemLabel = itemLabel.toString();
}
Object itemDescription = attributeMap.get(ITEM_DESCRIPTION_ATTR);
if (itemDescription != null)
{
itemDescription = itemDescription.toString();
}
Boolean itemDisabled = getBooleanAttribute(_currentUISelectItems, ITEM_DISABLED_ATTR, false);
Boolean itemLabelEscaped = getBooleanAttribute(_currentUISelectItems, ITEM_LABEL_ESCAPED_ATTR, true);
Object noSelectionValue = attributeMap.get(NO_SELECTION_VALUE_ATTR);
item = new SelectItem(itemValue,
(String) itemLabel,
(String) itemDescription,
itemDisabled,
itemLabelEscaped,
itemValue.equals(noSelectionValue));