craigmcc 01/01/27 12:09:44
Modified: src/doc struts-html.xml
src/share/org/apache/struts/taglib/html ErrorsTag.java
Log:
Add a "property" attribute to <html:errors/> so that you can extract just
the error messages for a particular property. By default, all error
messages for all properties are extracted (which was the previous
behavior).
Submitted by: Howard Moore <[EMAIL PROTECTED]>
Revision Changes Path
1.3 +11 -0 jakarta-struts/src/doc/struts-html.xml
Index: struts-html.xml
===================================================================
RCS file: /home/cvs/jakarta-struts/src/doc/struts-html.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- struts-html.xml 2001/01/11 00:29:51 1.2
+++ struts-html.xml 2001/01/27 20:09:42 1.3
@@ -714,6 +714,17 @@
</info>
</attribute>
+ <attribute>
+ <name>property</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <info>
+ Name of the property for which error messages should be
+ displayed. If not specified, all error messages (regardless
+ of property) are displayed.
+ </info>
+ </attribute>
+
</tag>
<tag>
1.3 +26 -5
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.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ErrorsTag.java 2001/01/25 19:18:17 1.2
+++ ErrorsTag.java 2001/01/27 20:09:43 1.3
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v 1.2
2001/01/25 19:18:17 craigmcc Exp $
- * $Revision: 1.2 $
- * $Date: 2001/01/25 19:18:17 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v 1.3
2001/01/27 20:09:43 craigmcc Exp $
+ * $Revision: 1.3 $
+ * $Date: 2001/01/27 20:09:43 $
*
* ====================================================================
*
@@ -96,7 +96,7 @@
* </ul>
*
* @author Craig R. McClanahan
- * @version $Revision: 1.2 $ $Date: 2001/01/25 19:18:17 $
+ * @version $Revision: 1.3 $ $Date: 2001/01/27 20:09:43 $
*/
public class ErrorsTag extends TagSupport {
@@ -126,6 +126,22 @@
}
+ /**
+ * The name of the property for which error messages should be returned,
+ * or <code>null</code> to return all errors.
+ */
+ protected String property = null;
+
+ public String getProperty() {
+ return (this.property);
+ }
+
+ public void setProperty(String property) {
+ this.property = property;
+ }
+
+
+
// ------------------------------------------------------- Public Methods
@@ -190,7 +206,11 @@
results.append(message);
results.append("\r\n");
}
- Iterator reports = errors.get();
+ Iterator reports = null;
+ if (property == null)
+ reports = errors.get();
+ else
+ reports = errors.get(property);
while (reports.hasNext()) {
ActionError report = (ActionError) reports.next();
if (messages != null)
@@ -234,6 +254,7 @@
super.release();
name = Action.ERROR_KEY;
+ property = null;
}