}
item = new SelectItem(itemValue, label, description, disabled, escape, noSelectionOption);
}
else if (!(item instanceof SelectItem))
{
ValueExpression expression = uiSelectItem.getValueExpression("value");
throw new IllegalArgumentException("ValueExpression '"
+ (expression == null ? null : expression.getExpressionString()) + "' of UISelectItem : "
+ RendererUtils.getPathToComponent(child) + " does not reference an Object of type SelectItem");
}
_nextItem = (SelectItem) item;
return true;
}
else if (child instanceof UISelectItems)
{
_currentUISelectItems = ((UISelectItems) child);
Object value = _currentUISelectItems.getValue();
if (value instanceof SelectItem)
{
_nextItem = (SelectItem) value;
return true;
}
else if (value != null && value.getClass().isArray())
{
// value is any kind of array (primitive or non-primitive)
// --> we have to use class Array to get the values
final int length = Array.getLength(value);
Collection<Object> items = new ArrayList<Object>(length);
for (int i = 0; i < length; i++)
{
items.add(Array.get(value, i));
}
_nestedItems = items.iterator();
return hasNext();
}
else if (value instanceof Iterable)
{
// value is Iterable --> Collection, DataModel,...
_nestedItems = ((Iterable<?>) value).iterator();
return hasNext();
}
else if (value instanceof Map)
{
Map<Object, Object> map = ((Map<Object, Object>) value);
Collection<SelectItem> items = new ArrayList<SelectItem>(map.size());
for (Map.Entry<Object, Object> entry : map.entrySet())
{
items.add(new SelectItem(entry.getValue(), entry.getKey().toString()));
}
_nestedItems = items.iterator();
return hasNext();
}
else
{
Level level = Level.FINE;
if (!FacesContext.getCurrentInstance().isProjectStage(ProjectStage.Production))
{
level = Level.WARNING;
}
if (log.isLoggable(level))
{
ValueExpression expression = _currentUISelectItems.getValueExpression("value");
log.log(level, "ValueExpression {0} of UISelectItems with component-path {1}"
+ " does not reference an Object of type SelectItem,"
+ " array, Iterable or Map, but of type: {2}",
new Object[] {
(expression == null ? null : expression.getExpressionString()),
RendererUtils.getPathToComponent(child),
(value == null ? null : value.getClass().getName())
});
}
}