(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;
} else {
JspException e = new JspException
(messages.getMessage("errorsTag.errors",
value.getClass().getName()));
RequestUtils.saveException(pageContext, e);
throw e;
}
} catch (Exception e) {
;
}
if (errors.empty())
return (EVAL_BODY_INCLUDE);
// Check for presence of header and footer message keys
boolean headerPresent =
RequestUtils.present(pageContext, bundle, locale, "errors.header");
boolean footerPresent =
RequestUtils.present(pageContext, bundle, locale, "errors.footer");
// Render the error messages appropriately
StringBuffer results = new StringBuffer();
String message = null;
if (headerPresent)
message = RequestUtils.message(pageContext, bundle,
locale, "errors.header");
Iterator reports = null;
if (property == null)
reports = errors.get();
else
reports = errors.get(property);
// Render header iff this is a global tag or there is an error for this property
boolean propertyMsgPresent = reports.hasNext();
if ((message != null)&&(property == null) || propertyMsgPresent) {
results.append(message);
results.append("\r\n");
}
while (reports.hasNext()) {
ActionError report = (ActionError) reports.next();
message = RequestUtils.message(pageContext, bundle,
locale, report.getKey(),
report.getValues());
if (message != null) {
results.append(message);
results.append("\r\n");
}
}