rleland 01/06/23 20:36:10
Modified: src/share/org/apache/struts/taglib/html Tag:
STRUTS_1_0_BRANCH ErrorsTag.java
Log:
Buzilla 2198 This is a limited patch that doesn't add arguments to the errors
tag, which is needed to fully cleanup error reporting.
Currently given:
<html:errors property="p1"/>
<html:errors property="p2"/>
<html:errors property="p3"/>
If there is an error for property "p1",
an errors.header will be printed for "p2" and "p3" also
regardless if there is an error
or not for that property !
The patch below restricts the printing of the header
to only those properties which have errors, and the global
<html:errors/> tag.
Revision Changes Path
No revision
No revision
1.8.2.1 +17 -13
jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java
Index: ErrorsTag.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -r1.8 -r1.8.2.1
--- ErrorsTag.java 2001/04/18 23:32:34 1.8
+++ ErrorsTag.java 2001/06/24 03:36:10 1.8.2.1
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v 1.8
2001/04/18 23:32:34 craigmcc Exp $
- * $Revision: 1.8 $
- * $Date: 2001/04/18 23:32:34 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v
1.8.2.1 2001/06/24 03:36:10 rleland Exp $
+ * $Revision: 1.8.2.1 $
+ * $Date: 2001/06/24 03:36:10 $
*
* ====================================================================
*
@@ -98,7 +98,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.8 $ $Date: 2001/04/18 23:32:34 $
+ * @version $Revision: 1.8.2.1 $ $Date: 2001/06/24 03:36:10 $
*/
public class ErrorsTag extends TagSupport {
@@ -237,30 +237,34 @@
if (headerPresent)
message = RequestUtils.message(pageContext, bundle,
locale, "errors.header");
- if (message != null) {
- results.append(message);
- results.append("\r\n");
- }
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");
+ if (message != null) {
+ results.append(message);
+ results.append("\r\n");
+ }
}
- }
message = null;
if (footerPresent)
message = RequestUtils.message(pageContext, bundle,
locale, "errors.footer");
- if (message != null) {
+
+ if ((message != null)&&(property == null) || propertyMsgPresent) {
results.append(message);
results.append("\r\n");
}