craigmcc 2002/06/22 21:38:44 Modified: doc/userGuide struts-html.xml src/share/org/apache/struts/taglib/html ErrorsTag.java Log: Implement a small enhancement to the HTML rendered by ErrorsTag -- if the "errors.prefix" and "errors.suffix" keys are defined in the application resources, the corresponding strings will be put before and after each individual message. This is a good place for <li> and </li> tags, for example. PR: Bugzilla #2164 Submitted by: Keith Egler <kegler at question.com> Revision Changes Path 1.11 +6 -2 jakarta-struts/doc/userGuide/struts-html.xml Index: struts-html.xml =================================================================== RCS file: /home/cvs/jakarta-struts/doc/userGuide/struts-html.xml,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- struts-html.xml 22 Jun 2002 21:54:56 -0000 1.10 +++ struts-html.xml 23 Jun 2002 04:38:44 -0000 1.11 @@ -923,8 +923,8 @@ <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 at least the - following message keys:</p> + bean under the default attribute name, with optional + definitions of the following message keys:</p> <ul> <li><strong>errors.header</strong> - Text that will be rendered before the error messages list. Typically, this message text @@ -934,6 +934,10 @@ after the error messages list. Typically, this message text will begin with <code></ul></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> </ul> </info> 1.15 +24 -7 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.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- ErrorsTag.java 17 Mar 2002 05:07:35 -0000 1.14 +++ ErrorsTag.java 23 Jun 2002 04:38:44 -0000 1.15 @@ -92,10 +92,13 @@ * messages exist for them in the application resources: * <ul> * <li><b>errors.header</b> - If present, the corresponding message will be - * rendered prior to the individual list of error messages. + * rendered prior to the individual list of error messages.</li> * <li><b>errors.footer</b> - If present, the corresponding message will be - * rendered following the individual list of error messages. - * <li><b> + * rendered following the individual list of error messages.</li> + * <li><b>errors.prefix</b> - If present, the corresponding message will be + * rendered before each individual error message.</li> + * <li><b>errors.suffix</b> - If present, the corresponding message will be + * rendered after each individual error message.</li> * </ul> * * @author Craig R. McClanahan @@ -206,6 +209,10 @@ RequestUtils.present(pageContext, bundle, locale, "errors.header"); boolean footerPresent = RequestUtils.present(pageContext, bundle, locale, "errors.footer"); + boolean prefixPresent = + RequestUtils.present(pageContext, bundle, locale, "errors.prefix"); + boolean suffixPresent = + RequestUtils.present(pageContext, bundle, locale, "errors.suffix"); // Render the error messages appropriately StringBuffer results = new StringBuffer(); @@ -228,12 +235,22 @@ } headerDone = true; } + if (prefixPresent) { + message = RequestUtils.message(pageContext, bundle, + locale, "errors.prefix"); + results.append(message); + } message = RequestUtils.message(pageContext, bundle, locale, report.getKey(), report.getValues()); if (message != null) { results.append(message); results.append("\r\n"); + } + if (suffixPresent) { + message = RequestUtils.message(pageContext, bundle, + locale, "errors.suffix"); + results.append(message); } } if (headerDone && footerPresent) {
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>