clazz = ReflectUtil.findClass(n2);
}
}
// If our second attempt didn't work, wrap the *original* exception
catch (Exception e2) {
throw new StripesJspException
("Could not process class [" + this.className + "]. Attribute 'enum' on " +
"tag options-enumeration must be the fully qualified name of a " +
"class which is a java 1.5 enum.", e);
}
}
if (!clazz.isEnum()) {
throw new StripesJspException
("The class name supplied, [" + this.className + "], does not appear to be " +
"a JDK1.5 enum class.");
}
Enum[] enums = clazz.getEnumConstants();
try {
Locale locale = getPageContext().getRequest().getLocale();
boolean attemptToLocalizeLabels = isAttemptToLocalizeLabels();
for (Enum item : enums) {
Object label = null;
String simpleName = LocalizationUtility.getSimpleName(clazz);
if (attemptToLocalizeLabels) {
String packageName = clazz.getPackage() == null ? "" : clazz.getPackage().getName();
// Check for a localized label using class.ENUM_VALUE and package.class.ENUM_VALUE
label = LocalizationUtility.getLocalizedFieldName(simpleName + "." + item.name(),
packageName,
null,
locale);
}
if (label == null) {
if (getLabel() != null) {
label = BeanUtil.getPropertyValue(getLabel(), item);
}
else {
label = item.toString();
}
}
Object group = null;
if (getGroup() != null)
group = BeanUtil.getPropertyValue(getGroup(), item);
addEntry(item, label, item, group);
}
}
catch (ExpressionException ee) {
throw new StripesJspException("A problem occurred generating an options-enumeration. " +
"Most likely either the class [" + getEnum() + "] is not an enum or, [" +
getLabel() + "] is not a valid property of the enum.", ee);
}
return SKIP_BODY;