struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: rev 51829 - in struts/trunk: doc/userGuide src/share/org/apache/struts/taglib/html src/test/org/apache/struts/taglib/bean/resources src/test/org/apache/struts/taglib/html web/test/test/org/apache/struts/taglib/html
Date Sun, 03 Oct 2004 09:40:58 GMT
Author: niallp
Date: Sun Oct  3 02:40:57 2004
New Revision: 51829

Modified:
   struts/trunk/doc/userGuide/struts-html.xml
   struts/trunk/doc/userGuide/struts-nested.xml
   struts/trunk/src/share/org/apache/struts/taglib/html/ErrorsTag.java
   struts/trunk/src/test/org/apache/struts/taglib/bean/resources/AlternateApplicationResources.properties
   struts/trunk/src/test/org/apache/struts/taglib/bean/resources/ApplicationResources.properties
   struts/trunk/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java
   struts/trunk/web/test/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp
Log:
Bug 13565 - Add header,footer,prefix,suffix attributes to ErrorsTag

Modified: struts/trunk/doc/userGuide/struts-html.xml
==============================================================================
--- struts/trunk/doc/userGuide/struts-html.xml	(original)
+++ struts/trunk/doc/userGuide/struts-html.xml	Sun Oct  3 02:40:57 2004
@@ -982,20 +982,21 @@
                 <p>In order to use this tag successfully, you must have
                 defined an application scope <code>MessageResources</code>
                 bean under the default attribute name, with optional
-                definitions of the following message keys:</p>
+                definitions of message keys specified in the following
+                attributes:</p>
                 <ul>
-                <li><strong>errors.header</strong> - Text that will be
rendered
+                <li><strong>header</strong> - Text that will be rendered
                 before the error messages list.  Typically, this message text
                 will end with <code>&lt;ul&gt;</code> to start the
-                error messages list.</li>
-                <li><strong>errors.footer</strong> - Text that will be
rendered
+                error messages list (default "errors.header").</li>
+                <li><strong>footer</strong> - Text that will be rendered
                 after the error messages list.  Typically, this message text
                 will begin with <code>&lt;/ul&gt;</code> to end the error
-                messages list.</li>
-                <li><strong>errors.prefix</strong> - Text that will be
rendered
-                before each individual error in the list.</li>
-                <li><strong>errors.suffix</strong> - Text that will be
rendered
-                after each individual error in the list.</li>
+                messages list (default "errors.footer").</li>
+                <li><strong>prefix</strong> - Text that will be rendered
+                before each individual error in the list (default "errors.prefix").</li>
+                <li><strong>suffix</strong> - Text that will be rendered
+                after each individual error in the list (default "errors.suffix").</li>
                 </ul>
                 </info>
 
@@ -1011,6 +1012,30 @@
                 </attribute>
 
                 <attribute>
+                  <name>footer</name>
+                  <required>false</required>
+                  <rtexprvalue>true</rtexprvalue>
+                  <info>
+                  This value is an optional message resource key that will
+                  be printed after the iteration of error messages has finished.
+                  Defaults to "errors.footer" if not specified.
+                  </info>
+                  <since>Struts 1.2.5</since>
+                </attribute>
+
+                <attribute>
+                  <name>header</name>
+                  <required>false</required>
+                  <rtexprvalue>true</rtexprvalue>
+                  <info>
+                  This value is an optional message resource key that will
+                  be printed before the iteration of error messages begins.
+                  Defaults to "errors.header" if not specified.
+                  </info>
+                  <since>Struts 1.2.5</since>
+                </attribute>
+
+                <attribute>
                     <name>locale</name>
                     <required>false</required>
                     <rtexprvalue>true</rtexprvalue>
@@ -1033,6 +1058,18 @@
                 </attribute>
 
                 <attribute>
+                  <name>prefix</name>
+                  <required>false</required>
+                  <rtexprvalue>true</rtexprvalue>
+                  <info>
+                  This value is an optional message resource key that will
+                  be printed before an error message.
+                  Defaults to "errors.prefix" if not specified.
+                  </info>
+                  <since>Struts 1.2.5</since>
+                </attribute>
+
+                <attribute>
                   <name>property</name>
                   <required>false</required>
                   <rtexprvalue>true</rtexprvalue>
@@ -1041,6 +1078,18 @@
                   displayed.  If not specified, all error messages (regardless
                   of property) are displayed.
                   </info>
+                </attribute>
+
+                <attribute>
+                  <name>suffix</name>
+                  <required>false</required>
+                  <rtexprvalue>true</rtexprvalue>
+                  <info>
+                  This value is an optional message resource key that will
+                  be printed after an error message.
+                  Defaults to "errors.suffix" if not specified.
+                  </info>
+                  <since>Struts 1.2.5</since>
                 </attribute>
 
         </tag>

Modified: struts/trunk/doc/userGuide/struts-nested.xml
==============================================================================
--- struts/trunk/doc/userGuide/struts-nested.xml	(original)
+++ struts/trunk/doc/userGuide/struts-nested.xml	Sun Oct  3 02:40:57 2004
@@ -676,6 +676,20 @@
      </attribute>
 
      <attribute>
+         <name>footer</name>
+         <required>false</required>
+         <rtexprvalue>true</rtexprvalue>
+         <since>Struts 1.2.5</since>
+     </attribute>
+
+     <attribute>
+         <name>header</name>
+         <required>false</required>
+         <rtexprvalue>true</rtexprvalue>
+         <since>Struts 1.2.5</since>
+     </attribute>
+
+     <attribute>
          <name>locale</name>
          <required>false</required>
          <rtexprvalue>true</rtexprvalue>
@@ -688,9 +702,23 @@
      </attribute>
 
      <attribute>
+         <name>prefix</name>
+         <required>false</required>
+         <rtexprvalue>true</rtexprvalue>
+         <since>Struts 1.2.5</since>
+     </attribute>
+
+     <attribute>
        <name>property</name>
        <required>false</required>
        <rtexprvalue>true</rtexprvalue>
+     </attribute>
+
+     <attribute>
+         <name>suffix</name>
+         <required>false</required>
+         <rtexprvalue>true</rtexprvalue>
+         <since>Struts 1.2.5</since>
      </attribute>
   </tag>
 

Modified: struts/trunk/src/share/org/apache/struts/taglib/html/ErrorsTag.java
==============================================================================
--- struts/trunk/src/share/org/apache/struts/taglib/html/ErrorsTag.java	(original)
+++ struts/trunk/src/share/org/apache/struts/taglib/html/ErrorsTag.java	Sun Oct  3 02:40:57
2004
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ErrorsTag.java,v
1.33 2004/03/14 06:23:46 sraeburn Exp $
  * $Revision: 1.33 $
- * $Date: 2004/03/14 06:23:46 $
+ * $Date$
  *
  * Copyright 1999-2004 The Apache Software Foundation.
  * 
@@ -52,7 +52,7 @@
  *     rendered after each individual error message.</li>
  * </ul>
  *
- * @version $Revision: 1.33 $ $Date: 2004/03/14 06:23:46 $
+ * @version $Revision: 1.33 $ $Date$
  */
 public class ErrorsTag extends TagSupport {
 
@@ -129,6 +129,58 @@
         this.property = property;
     }
 
+    /**
+     * The message resource key for errors header.
+     */
+    protected String header = null;
+
+    public String getHeader() {
+        return header == null ? "errors.header" : header;
+    }
+
+    public void setHeader(String header) {
+        this.header = header;
+    }
+
+    /**
+     * The message resource key for errors footer.
+     */
+    protected String footer = null;
+
+    public String getFooter() {
+        return footer == null ? "errors.footer" : footer;
+    }
+
+    public void setFooter(String footer) {
+        this.footer = footer;
+    }
+
+    /**
+     * The message resource key for errors prefix.
+     */
+    protected String prefix= null;
+
+    public String getPrefix() {
+        return prefix == null ? "errors.prefix" : prefix;
+    }
+
+    public void setPrefix(String prefix) {
+        this.prefix= prefix;
+    }
+
+    /**
+     * The message resource key for errors suffix.
+     */
+    protected String suffix= null;
+
+    public String getSuffix() {
+        return suffix == null ? "errors.suffix" : suffix;
+    }
+
+    public void setSuffix(String suffix) {
+        this.suffix= suffix;
+    }
+
     // ------------------------------------------------------- Public Methods
 
     /**
@@ -152,16 +204,16 @@
         }
 
         boolean headerPresent =
-            TagUtils.getInstance().present(pageContext, bundle, locale, "errors.header");
+            TagUtils.getInstance().present(pageContext, bundle, locale, getHeader());
 
         boolean footerPresent =
-            TagUtils.getInstance().present(pageContext, bundle, locale, "errors.footer");
+            TagUtils.getInstance().present(pageContext, bundle, locale, getFooter());
 
         boolean prefixPresent =
-            TagUtils.getInstance().present(pageContext, bundle, locale, "errors.prefix");
+            TagUtils.getInstance().present(pageContext, bundle, locale, getPrefix());
 
         boolean suffixPresent =
-            TagUtils.getInstance().present(pageContext, bundle, locale, "errors.suffix");
+            TagUtils.getInstance().present(pageContext, bundle, locale, getSuffix());
 
         // Render the error messages appropriately
         StringBuffer results = new StringBuffer();
@@ -178,7 +230,7 @@
                             pageContext,
                             bundle,
                             locale,
-                            "errors.header");
+                            getHeader());
                             
                     results.append(message);
                 }
@@ -191,7 +243,7 @@
                         pageContext,
                         bundle,
                         locale,
-                        "errors.prefix");
+                        getPrefix());
                 results.append(message);
             }
             
@@ -213,14 +265,14 @@
                         pageContext,
                         bundle,
                         locale,
-                        "errors.suffix");
+                        getSuffix());
                 results.append(message);
             }
         }
         
         if (headerDone && footerPresent) {
             message =
-                TagUtils.getInstance().message(pageContext, bundle, locale, "errors.footer");
+                TagUtils.getInstance().message(pageContext, bundle, locale, getFooter());
             results.append(message);
         }
 
@@ -239,6 +291,10 @@
         locale = Globals.LOCALE_KEY;
         name = Globals.ERROR_KEY;
         property = null;
+        header = null;
+        footer = null;
+        prefix = null;
+        suffix = null;
     }
 
 }

Modified: struts/trunk/src/test/org/apache/struts/taglib/bean/resources/AlternateApplicationResources.properties
==============================================================================
--- struts/trunk/src/test/org/apache/struts/taglib/bean/resources/AlternateApplicationResources.properties
(original)
+++ struts/trunk/src/test/org/apache/struts/taglib/bean/resources/AlternateApplicationResources.properties
Sun Oct  3 02:40:57 2004
@@ -18,3 +18,5 @@
 
 custom.alternate.errors.header=custom_alternate_error_header
 custom.alternate.errors.footer=custom_alternate_error_footer
+custom.alternate.errors.prefix=<custom_alternate_error_prefix>
+custom.alternate.errors.suffix=<custom_alternate_error_suffix>

Modified: struts/trunk/src/test/org/apache/struts/taglib/bean/resources/ApplicationResources.properties
==============================================================================
--- struts/trunk/src/test/org/apache/struts/taglib/bean/resources/ApplicationResources.properties
(original)
+++ struts/trunk/src/test/org/apache/struts/taglib/bean/resources/ApplicationResources.properties
Sun Oct  3 02:40:57 2004
@@ -18,3 +18,5 @@
 
 custom.errors.header=custom_error_header
 custom.errors.footer=custom_error_footer
+custom.errors.prefix=<custom_error_prefix>
+custom.errors.suffix=<custom_error_suffix>

Modified: struts/trunk/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java
==============================================================================
--- struts/trunk/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java	(original)
+++ struts/trunk/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java	Sun Oct  3 02:40:57
2004
@@ -1,7 +1,7 @@
 /*
  * $Header: /home/cvs/jakarta-struts/src/test/org/apache/struts/taglib/html/TestErrorsTag2.java,v
1.10 2004/03/14 06:23:40 sraeburn Exp $
  * $Revision: 1.10 $
- * $Date: 2004/03/14 06:23:40 $
+ * $Date$
  *
  * Copyright 1999-2004 The Apache Software Foundation.
  * 
@@ -213,5 +213,11 @@
         }
 
 
+    public void testErrorsCustomResources() throws Exception {
+        runMyTest("testErrorsCustomResources", "");
+    }
+    public void testErrorsCustomResourcesAltBundle() throws Exception {
+        runMyTest("testErrorsCustomResourcesAltBundle", "");
+    }
 
 }

Modified: struts/trunk/web/test/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp
==============================================================================
--- struts/trunk/web/test/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp	(original)
+++ struts/trunk/web/test/test/org/apache/struts/taglib/html/TestErrorsTag2.jsp	Sun Oct  3
02:40:57 2004
@@ -480,6 +480,42 @@
 
 
 
+<logic:equal name="runTest" value="testErrorsCustomResources">
+<%
+//This should be done in your action.  I do it here to keep the tests simple.
+	ActionErrors errors = new ActionErrors();
+    errors.add(ActionErrors.GLOBAL_ERROR,
+         new ActionError("default.testing.errors.tag"));
+    errors.add(ActionErrors.GLOBAL_ERROR,
+         new ActionError("default.testing.errors.tag2"));
+    request.setAttribute(Globals.ERROR_KEY, errors);
+%>
+	<bean:define id="EXPECTED_RESULTS" toScope="page">
+		My Errors go here:<html:errors header="custom.errors.header" footer="custom.errors.footer"
prefix="custom.errors.prefix" suffix="custom.errors.suffix"/>
+	</bean:define>
+	<bean:define id="TEST_RESULTS" toScope="page">
+		My Errors go here:custom_error_header<custom_error_prefix>My Errors Text<custom_error_suffix><custom_error_prefix>My
Errors Text 2<custom_error_suffix>custom_error_footer
+	</bean:define>
+</logic:equal>
+
+<logic:equal name="runTest" value="testErrorsCustomResourcesAltBundle">
+<%
+//This should be done in your action.  I do it here to keep the tests simple.
+	ActionErrors errors = new ActionErrors();
+    errors.add(ActionErrors.GLOBAL_ERROR,
+         new ActionError("alternate.testing.errors.tag"));
+    errors.add(ActionErrors.GLOBAL_ERROR,
+         new ActionError("alternate.testing.errors.tag2"));
+    request.setAttribute(Globals.ERROR_KEY, errors);
+%>
+	<bean:define id="EXPECTED_RESULTS" toScope="page">
+		My Errors go here:<html:errors bundle="alternate" header="custom.alternate.errors.header"
footer="custom.alternate.errors.footer" prefix="custom.alternate.errors.prefix" suffix="custom.alternate.errors.suffix"/>
+	</bean:define>
+	<bean:define id="TEST_RESULTS" toScope="page">
+		My Errors go here:custom_alternate_error_header<custom_alternate_error_prefix>My
Alternate Errors Text<custom_alternate_error_suffix><custom_alternate_error_prefix>My
Alternate Errors Text 2<custom_alternate_error_suffix>custom_alternate_error_footer
+	</bean:define>
+</logic:equal>
+
 <% 
 String expected = "";
 String compareTo = "";

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message