return reportAndExit(EVAL_PAGE);
_state.disabled = isDisabled();
//Create hidden field for state tracking
ByRef ref = new ByRef();
nameHtmlControl(_state, ref);
if (hasErrors())
return reportAndExit(EVAL_PAGE);
// Only write out the hidden field if the select is not
// disabled. If it is disabled, then nothing will be posted
// back from this.
WriteRenderAppender writer = new WriteRenderAppender(pageContext);
if (!_state.disabled) {
_hiddenState.clear();
String hiddenParamName = null;
hiddenParamName = _state.name + OLDVALUE_SUFFIX;
_hiddenState.name = hiddenParamName;
_hiddenState.value = "true";
TagRenderingBase hiddenTag = TagRenderingBase.Factory.getRendering(TagRenderingBase.INPUT_HIDDEN_TAG, req);
hiddenTag.doStartTag(writer, _hiddenState);
hiddenTag.doEndTag(writer);
write("\n");
}
// Render any formatting errors that may have occurred.
if (fmtErrors != null)
write(fmtErrors);
TagRenderingBase br = TagRenderingBase.Factory.getRendering(TagRenderingBase.SELECT_TAG, req);
br.doStartTag(writer, _state);
// Render the content of the body, these would be the options
if (_saveBody != null) {
write(_saveBody);
}
// if we are repeating then the body contained the options so we can exit here
if (_repeater) {
if (hasErrors())
return reportAndExit(EVAL_PAGE);
br.doEndTag(writer);
if (!ref.isNull())
write((String) ref.getRef());
// Continue processing this page
localRelease();
return EVAL_PAGE;
}
// All of the code below will pass through the optionsDataSource, the dataSource and defaultValue and
// create a full Select.
if (_dynamicOptions != null) {
if (_dynamicOptions instanceof Map) {
Map dynamicOptionsMap = (Map) _dynamicOptions;
Iterator keyIterator = dynamicOptionsMap.keySet().iterator();
while (keyIterator.hasNext()) {
Object optionValue = keyIterator.next();
String optionDisplay = null;
if (dynamicOptionsMap.get(optionValue) != null) {
optionDisplay = dynamicOptionsMap.get(optionValue).toString();
}
if (optionValue != null) {
addOption(req, optionValue.toString(), optionDisplay);
}
}
}
else if (_dynamicOptions instanceof Iterator) {
Iterator dynamicOptionsIterator = (Iterator) evaluateOptionsDataSource();
while (dynamicOptionsIterator.hasNext()) {
Object o = dynamicOptionsIterator.next();
if (o != null) {
String optionValue = o.toString();
addOption(req, optionValue, optionValue);
}
}
}
}
// add the value from the DataSource and Default value
addDatasourceIfNeeded(req);
addDefaultsIfNeeded(req);
if (_nullable && !isMultiple()) {
String txt = (_nullableOptionText != null) ? _nullableOptionText : "";
addOption(req, NULL_VALUE, txt);
}
br.doEndTag(writer);
if (!ref.isNull())
write((String) ref.getRef());
// Continue processing this page
localRelease();
return EVAL_PAGE;
}