in tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SelectManyRendererBase.java [629:704]
public SelectItem next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
if (nextItem != null) {
final 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
final 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) {
if (itemValue != null) {
itemLabel = itemValue.toString();
}
} else {
itemLabel = itemLabel.toString();
}
Object itemDescription = attributeMap.get(ITEM_DESCRIPTION_ATTR);
if (itemDescription != null) {
itemDescription = itemDescription.toString();
}
final Boolean itemDisabled = getBooleanAttribute(currentUISelectItems, ITEM_DISABLED_ATTR, false);
final Boolean itemLabelEscaped = getBooleanAttribute(currentUISelectItems, ITEM_LABEL_ESCAPED_ATTR, true);
final Object noSelectionValue = attributeMap.get(NO_SELECTION_VALUE_ATTR);
item = new SelectItem(itemValue,
(String) itemLabel,
(String) itemDescription,
itemDisabled,
itemLabelEscaped,
itemValue.equals(noSelectionValue));
// remove the value with the key from var from the request map, if previously written
if (wroteRequestMapVarValue) {
// If there was a previous value stored with the key from var in the request map, restore it
if (oldRequestMapVarValue != null) {
facesContext.getExternalContext()
.getRequestMap().put(var, oldRequestMapVarValue);
} else {
facesContext.getExternalContext()
.getRequestMap().remove(var);
}
}
}
return (SelectItem) item;
}
throw new NoSuchElementException();
}