// Acquire the select tag we are associated with
CVSelectTag selectTag = (CVSelectTag) pageContext.getAttribute(Constants.SELECT_KEY);
if (selectTag == null) {
JspException e = new JspException(messages.getMessage("optionsCollectionTag.select"));
RequestUtils.saveException(pageContext, e);
throw e;
}
// Acquire the collection containing our options
Object collection = RequestUtils.lookup(pageContext, name, property, null);
if (collection == null) {
JspException e =
new JspException(messages.getMessage("optionsCollectionTag.collection"));
RequestUtils.saveException(pageContext, e);
throw e;
}
// Acquire an iterator over the options collection
Iterator iter = getIterator(collection);
StringBuffer sb = new StringBuffer();
// Render the options
while (iter.hasNext()) {
Object bean = iter.next();
Object beanLabel = null;
Object beanValue = null;
// Get the label for this option
try {
beanLabel = PropertyUtils.getProperty(bean, label);
if (beanLabel == null) {
beanLabel = "";
}
} catch (IllegalAccessException e) {
JspException jspe =
new JspException(messages.getMessage("getter.access", label, bean));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
JspException jspe =
new JspException(messages.getMessage("getter.result", label, t.toString()));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
} catch (NoSuchMethodException e) {
JspException jspe =
new JspException(messages.getMessage("getter.method", label, bean));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
}
// Get the value for this option
try {
beanValue = PropertyUtils.getProperty(bean, value);
if (beanValue == null) {
beanValue = "";
}
} catch (IllegalAccessException e) {
JspException jspe =
new JspException(messages.getMessage("getter.access", value, bean));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
JspException jspe =
new JspException(messages.getMessage("getter.result", value, t.toString()));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
} catch (NoSuchMethodException e) {
JspException jspe =
new JspException(messages.getMessage("getter.method", value, bean));
RequestUtils.saveException(pageContext, jspe);
throw jspe;
}
String stringLabel = beanLabel.toString();