(name, PageContext.REQUEST_SCOPE);
if (value == null) {
;
} else if (value instanceof String) {
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError((String) value));
} else if (value instanceof String[]) {
String keys[] = (String[]) value;
for (int i = 0; i < keys.length; i++)
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError(keys[i]));
} else if (value instanceof ErrorMessages) {
String keys[] = ((ErrorMessages) value).getErrors();
if (keys == null)
keys = new String[0];
for (int i = 0; i < keys.length; i++)
errors.add(ActionErrors.GLOBAL_ERROR,
new ActionError(keys[i]));
} else if (value instanceof ActionErrors) {
errors = (ActionErrors) value;
}
} catch (Exception e) {
;
}
if (errors.empty())
return (EVAL_BODY_INCLUDE);
// Render the error messages appropriately
Locale locale = null;
try {
locale = (Locale) pageContext.getAttribute
(Action.LOCALE_KEY, PageContext.SESSION_SCOPE);
} catch (IllegalStateException e) { // Invalidated session
locale = null;
}
if (locale == null)
locale = defaultLocale;
MessageResources messages = (MessageResources)
pageContext.getAttribute(Action.MESSAGES_KEY,
PageContext.APPLICATION_SCOPE);
String message = null;
StringBuffer results = new StringBuffer();
message = messages.getMessage(locale, "errors.header");
if (message != null) {
results.append(message);
results.append("\r\n");
}
Iterator reports = errors.get();
while (reports.hasNext()) {
ActionError report = (ActionError) reports.next();
message =
messages.getMessage(locale,
report.getKey(), report.getValues());
if (message != null) {
results.append(message);
results.append("\r\n");
}
}