else if (_selectedValues != null)
{
selections = _selectedValues.valueInComponent(parent);
}
NSMutableArray selectedObjects = null;
if (selections != null) {
if ( ! (selections instanceof NSArray)) {
selectedObjects = new NSMutableArray(selections);
}
else if ( !(selections instanceof NSMutableArray)) {
selectedObjects = new NSMutableArray((NSArray)selections);
}
else {
selectedObjects = (NSMutableArray)selections;
}
}
NSArray list = (NSArray) _list.valueInComponent(parent);
Object previousGroup = null;
boolean didOpenOptionGroup = false;
boolean shouldEscapeHTML = _escapeHTML != null ? _escapeHTML.booleanValueInComponent(parent) : true;
for(int i = 0; i < list.count(); i++)
{
Object listItem = list.objectAtIndex(i);
_item.setValue(listItem, parent);
Object currentGroup = group.valueInComponent(parent);
if ( ! currentGroup.equals(previousGroup))
{
previousGroup = currentGroup;
if (didOpenOptionGroup)
{
response._appendContentAsciiString("\n</optgroup>");
}
response._appendContentAsciiString("\n<optgroup label=\"");
if (label != null)
{
if (shouldEscapeHTML)
{
response.appendContentHTMLString(label.valueInComponent(parent).toString());
}
else
{
response.appendContentString(label.valueInComponent(parent).toString());
}
}
response._appendContentAsciiString("\">");
didOpenOptionGroup = true;
}
response._appendContentAsciiString("\n<option");
if (itemStyle != null) {
String style = (String) itemStyle.valueInComponent(parent);
if (style != null) {
response._appendTagAttributeAndValue("style", style, true);
}
}
if (itemClass != null) {
String cssClass = (String) itemClass.valueInComponent(parent);
if (cssClass != null) {
response._appendTagAttributeAndValue("class", cssClass, true);
}
}
String valueAsString = null;
String displayStringAsString = null;
if (_displayString != null || _value != null)
{
if (_displayString != null)
{
Object displayString = _displayString.valueInComponent(parent);
if (displayString != null)
{
displayStringAsString = displayString.toString();
if (_value != null)
{
Object value = _value.valueInComponent(parent);
if (value != null)
{
valueAsString = value.toString();
}
}
else
{
valueAsString = displayStringAsString;
}
}
}
else
{
Object value = _value.valueInComponent(parent);
if (value != null)
{
valueAsString = value.toString();
displayStringAsString = valueAsString;
}
}
}
else
{
displayStringAsString = listItem.toString();
valueAsString = displayStringAsString;
}
boolean isSelectedItem = false;
if (_selections != null)
{
isSelectedItem = selectedObjects == null ? false : selectedObjects.containsObject(listItem);
}
else if (_selectedValues != null)
{
if (_value != null)
{
isSelectedItem = selectedObjects == null ? false : selectedObjects.containsObject(valueAsString);
}
}
if (isSelectedItem)
{