Attched is a patch file for a number of tags in the html package. Niall -----Original Message----- From: Niall Pemberton [mailto:[EMAIL PROTECTED]] Sent: 14 May 2001 02:00 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: RE: [Bug 1683] Changed - Change Struts tags to be more granular in their design Attached is a patch file. Niall > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: 10 May 2001 03:30 > To: [EMAIL PROTECTED]; [EMAIL PROTECTED] > Subject: [Bug 1683] Changed - Change Struts tags to be more granular in > their design > > > http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1683 > > *** shadow/1683 Wed May 9 10:20:03 2001 > --- shadow/1683.tmp.15994 Wed May 9 19:29:35 2001 > *************** > *** 5,11 **** > | Status: NEW Version: 1.0 Beta 1 > | > | Resolution: Platform: Other > | > | Severity: Enhancement OS/Version: Other > | > ! | Priority: Component: Custom > Tags | > > +----------------------------------------------------------------- > -----------+ > | Assigned To: [EMAIL PROTECTED] > | > | Reported By: [EMAIL PROTECTED] > | > --- 5,11 ---- > | Status: NEW Version: 1.0 Beta 1 > | > | Resolution: Platform: Other > | > | Severity: Enhancement OS/Version: Other > | > ! | Priority: High Component: Custom > Tags | > > +----------------------------------------------------------------- > -----------+ > | Assigned To: [EMAIL PROTECTED] > | > | Reported By: [EMAIL PROTECTED] > | > *************** > *** 55,58 **** > > > P.S. I would be happy to help with this, although I havent used > Ant or CVS and > ! am not currently set up to do that. > --- 55,68 ---- > > > P.S. I would be happy to help with this, although I havent used > Ant or CVS and > ! am not currently set up to do that. > ! > ! ------- Additional Comments From [EMAIL PROTECTED] > 2001-05-09 19:29 ------- > ! This is a good idea. > ! > ! If you could provide unified diffs of the recommended changes, > as described on > ! the Jakarta web site: > ! > ! http://jakarta.apache.org/site/source.html > ! > ! that would be ideal, because they can be applied in an > automated fashion. >
cvs diff -u d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html cvs server: Diffing d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java,v retrieving revision 1.7 diff -u -r1.7 BaseFieldTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java 2001/04/29 00:38:04 1.7 +++ +d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java +2001/05/14 00:58:14 @@ -74,7 +74,6 @@ import org.apache.struts.util.RequestUtils; import org.apache.struts.util.ResponseUtils; - /** * Convenience base class for the various input tags for text fields. * @@ -153,34 +152,68 @@ // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\""); results.append(type); - results.append("\" name=\""); + results.append("\""); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + + results.append(">"); + + // Print this field to our output writer + ResponseUtils.write(pageContext, results.toString()); + + // Continue processing this page + return (EVAL_BODY_TAG); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("accept", accept)); + results.append(prepareAttribute("maxlength", maxlength)); + results.append(prepareAttribute("size", cols)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); results.append(property); results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (accept != null) { - results.append(" accept=\""); - results.append(accept); - results.append("\""); - } - if (maxlength != null) { - results.append(" maxlength=\""); - results.append(maxlength); - results.append("\""); - } - if (cols != null) { - results.append(" size=\""); - results.append(cols); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + results.append(" value=\""); if (value != null) { results.append(ResponseUtils.filter(value)); @@ -192,15 +225,6 @@ results.append(ResponseUtils.filter(value.toString())); } results.append("\""); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); - results.append(">"); - - // Print this field to our output writer - ResponseUtils.write(pageContext, results.toString()); - - // Continue processing this page - return (EVAL_BODY_TAG); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v retrieving revision 1.3 diff -u -r1.3 BaseHandlerTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java 2001/05/05 00:54:33 1.3 +++ +d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java + 2001/05/14 00:58:16 @@ -589,7 +589,19 @@ } + /** + * Format attribute="value" from the supplied attribute & value, with the + * value enclosed in quotes. + * + * @param attribute The name of the attribute + * @param value The value of the attribute + * + */ + protected String prepareAttribute(String attribute, String value) { + return value == null ? "" : " " + attribute + "=\"" + value + "\""; + + } } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v retrieving revision 1.3 diff -u -r1.3 ButtonTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java 2001/04/18 01:31:14 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java + 2001/05/14 00:58:17 @@ -151,44 +151,21 @@ return (EVAL_BODY_TAG); } - + /** * Process the end of this tag. * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { - // Acquire the label value we will be generating - String label = value; - if ((label == null) && (text != null)) - label = text; - if ((label == null) || (label.trim().length() < 1)) - label = "Click"; - // Generate an HTML element StringBuffer results = new StringBuffer(); results.append("<input type=\"button\""); - if (property != null) { - results.append(" name=\""); - results.append(property); - results.append("\""); - } - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - results.append(label); - results.append("\""); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Render this element to our writer @@ -199,6 +176,62 @@ } + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + // Acquire the label value we will be generating + String label = value; + if ((label == null) && (text != null)) + label = text; + if ((label == null) || (label.trim().length() < 1)) + label = "Click"; + + results.append(" value=\""); + results.append(label); + results.append("\""); + + } /** * Release any acquired resources. Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java,v retrieving revision 1.3 diff -u -r1.3 CancelTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java 2001/04/18 01:31:14 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java + 2001/05/14 00:58:18 @@ -185,34 +185,13 @@ */ public int doEndTag() throws JspException { - // Acquire the label value we will be generating - String label = value; - if ((label == null) && (text != null)) - label = text; - if ((label == null) || (label.trim().length() < 1)) - label = "Cancel"; - // Generate an HTML element StringBuffer results = new StringBuffer(); results.append("<input type=\"submit\""); - results.append(" name=\""); - results.append(property); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - results.append(label); - results.append("\""); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Render this element to our writer @@ -220,6 +199,64 @@ // Evaluate the remainder of this page return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + // Acquire the label value we will be generating + String label = value; + if ((label == null) && (text != null)) + label = text; + if ((label == null) || (label.trim().length() < 1)) + label = "Cancel"; + + + results.append(" value=\""); + results.append(label); + results.append("\""); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v retrieving revision 1.4 diff -u -r1.4 CheckboxTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java 2001/04/18 01:31:14 1.4 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java + 2001/05/14 00:58:19 @@ -183,38 +183,10 @@ // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\"checkbox\""); - results.append(" name=\""); - results.append(this.property); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - if (value == null) - results.append("on"); - else - results.append(value); - results.append("\""); - Object result = RequestUtils.lookup(pageContext, name, - property, null); - if (result == null) - result = ""; - if (!(result instanceof String)) - result = result.toString(); - String checked = (String) result; - if (checked.equalsIgnoreCase("true") - || checked.equalsIgnoreCase("yes") - || checked.equalsIgnoreCase("on")) - results.append(" checked"); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Print this field to our output writer @@ -258,6 +230,70 @@ // Evaluate the remainder of this page return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + results.append(" value=\""); + if (value == null) + results.append("on"); + else + results.append(value); + results.append("\""); + Object result = RequestUtils.lookup(pageContext, name, + property, null); + if (result == null) + result = ""; + if (!(result instanceof String)) + result = result.toString(); + String checked = (String) result; + if (checked.equalsIgnoreCase("true") + || checked.equalsIgnoreCase("yes") + || checked.equalsIgnoreCase("on")) + results.append(" checked"); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java,v retrieving revision 1.8 diff -u -r1.8 ImageTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java 2001/04/19 21:09:30 1.8 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java + 2001/05/14 00:58:21 @@ -98,7 +98,7 @@ // ------------------------------------------------------------- Properties - + /** * The alternate text for this image. */ @@ -263,47 +263,12 @@ public int doEndTag() throws JspException { // Generate an HTML <input type="image"> element - HttpServletResponse response = - (HttpServletResponse) pageContext.getResponse(); - String tmp = null; StringBuffer results = new StringBuffer(); - results.append("<input type=\"image\" name=\""); - results.append(property); - results.append("\""); - tmp = src(); - if (tmp != null) { - results.append(" src=\""); - results.append(response.encodeURL(tmp)); - results.append("\""); - } - tmp = alt(); - if (tmp != null) { - results.append(" alt=\""); - results.append(tmp); - results.append("\""); - } - if (border != null) { - results.append(" border=\""); - results.append(border); - results.append("\""); - } - if (value != null) { - results.append(" value=\""); - results.append(value); - results.append("\""); - } - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + results.append("<input type=\"image\""); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Render this element to our writer @@ -336,6 +301,99 @@ // ------------------------------------------------------ Protected Methods + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + prepareSrc(results); + prepareAlt(results); + + results.append(prepareAttribute("border", border)); + + prepareValue(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + if (value != null) { + results.append(" value=\""); + results.append(value); + results.append("\""); + } + + } + + /** + * Prepares the source attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareSrc(StringBuffer results) throws JspException { + + HttpServletResponse response = + (HttpServletResponse) pageContext.getResponse(); + + String tmp = src(); + if (tmp != null) { + results.append(" src=\""); + results.append(response.encodeURL(tmp)); + results.append("\""); + } + + } + /** + * Prepares the alt attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAlt(StringBuffer results) throws JspException { + + String tmp = alt(); + if (tmp != null) { + results.append(" alt=\""); + results.append(tmp); + results.append("\""); + } + + } /** * Return the alternate text to be included on this generated element, Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v retrieving revision 1.10 diff -u -r1.10 ImgTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java 2001/04/29 00:38:04 1.10 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java + 2001/05/14 00:58:23 @@ -499,77 +499,11 @@ public int doEndTag() throws JspException { // Generate the name definition or image element - HttpServletRequest request = - (HttpServletRequest) pageContext.getRequest(); - HttpServletResponse response = - (HttpServletResponse) pageContext.getResponse(); - StringBuffer results = new StringBuffer("<img"); - String tmp = src(); - String srcurl = url(tmp); - if (srcurl != null) { - results.append(" src=\""); - results.append(response.encodeURL(srcurl)); - results.append("\""); - } - String lowsrcurl = url(this.lowsrc); - if (lowsrcurl != null) { - results.append(" lowsrc=\""); - results.append(response.encodeURL(lowsrcurl)); - results.append("\""); - } - tmp = alt(); - if (tmp != null) { - results.append(" alt=\""); - results.append(tmp); - results.append("\""); - } - if (imageName != null) { - results.append(" name=\""); - results.append(imageName); - results.append("\""); - } - if (height != null) { - results.append(" height=\""); - results.append(height); - results.append("\""); - } - if (width != null) { - results.append(" width=\""); - results.append(width); - results.append("\""); - } - if (align != null) { - results.append(" align=\""); - results.append(align); - results.append("\""); - } - if (border != null) { - results.append(" border=\""); - results.append(border); - results.append("\""); - } - if (hspace != null) { - results.append(" hspace=\""); - results.append(hspace); - results.append("\""); - } - if (vspace != null) { - results.append(" vspace=\""); - results.append(vspace); - results.append("\""); - } - if (ismap != null) { - results.append(" ismap=\""); - results.append(ismap); - results.append("\""); - } - if (usemap != null) { - results.append(" usemap=\""); - results.append(usemap); - results.append("\""); - } - results.append(prepareStyles()); - results.append(prepareEventHandlers()); + StringBuffer results = new StringBuffer("<img"); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Print this element to our output writer @@ -617,6 +551,93 @@ // ------------------------------------------------------ Protected Methods + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareSrc(results); + prepareAlt(results); + prepareName(results); + + results.append(prepareAttribute("height", height)); + results.append(prepareAttribute("width", width)); + results.append(prepareAttribute("align", align)); + results.append(prepareAttribute("border", border)); + results.append(prepareAttribute("hspace", hspace)); + results.append(prepareAttribute("vspace", vspace)); + results.append(prepareAttribute("ismap", ismap)); + results.append(prepareAttribute("usemap", usemap)); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + if (imageName != null) { + results.append(" name=\""); + results.append(imageName); + results.append("\""); + } + + } + + /** + * Prepares the source attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareSrc(StringBuffer results) throws JspException { + + HttpServletResponse response = + (HttpServletResponse) pageContext.getResponse(); + + String tmp = src(); + String srcurl = url(tmp); + if (srcurl != null) { + results.append(" src=\""); + results.append(response.encodeURL(srcurl)); + results.append("\""); + } + String lowsrcurl = url(this.lowsrc); + if (lowsrcurl != null) { + results.append(" lowsrc=\""); + results.append(response.encodeURL(lowsrcurl)); + results.append("\""); + } + + } + /** + * Prepares the alt attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAlt(StringBuffer results) throws JspException { + + String tmp = alt(); + if (tmp != null) { + results.append(" alt=\""); + results.append(tmp); + results.append("\""); + } + + } /** * Return the alternate text to be included on this generated element, Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java,v retrieving revision 1.6 diff -u -r1.6 MultiboxTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java 2001/04/18 23:45:02 1.6 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java + 2001/05/14 00:58:24 @@ -224,19 +224,64 @@ // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\"checkbox\""); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + + results.append(">"); + + // Render this element to our response + ResponseUtils.write(pageContext, results.toString()); + + // Continue evaluating this page + return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + results.append(" name=\""); - results.append(this.property); + results.append(property); results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + results.append(" value=\""); String value = this.value; if (value == null) @@ -277,15 +322,6 @@ break; } } - results.append(prepareEventHandlers()); - results.append(prepareStyles()); - results.append(">"); - - // Render this element to our response - ResponseUtils.write(pageContext, results.toString()); - - // Continue evaluating this page - return (EVAL_PAGE); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v retrieving revision 1.3 diff -u -r1.3 RadioTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java 2001/04/18 01:31:15 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java + 2001/05/14 00:58:25 @@ -72,7 +72,6 @@ import org.apache.struts.util.MessageResources; import org.apache.struts.util.ResponseUtils; - /** * Tag for input fields of type "radio". * @@ -182,51 +181,13 @@ */ public int doStartTag() throws JspException { - // Acquire the current value of the appropriate field - Object current = null; - Object bean = pageContext.findAttribute(name); - if (bean == null) - throw new JspException - (messages.getMessage("getter.bean", name)); - try { - current = BeanUtils.getProperty(bean, property); - if (current == null) - current = ""; - } catch (IllegalAccessException e) { - throw new JspException - (messages.getMessage("getter.access", property, name)); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - throw new JspException - (messages.getMessage("getter.result", - property, t.toString())); - } catch (NoSuchMethodException e) { - throw new JspException - (messages.getMessage("getter.method", property, name)); - } - // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<input type=\"radio\""); - results.append(" name=\""); - results.append(this.property); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - results.append(this.value); - results.append("\""); - if (value.equals(current)) - results.append(" checked"); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Print this field to our output writer @@ -269,6 +230,81 @@ // Evaluate the remainder of this page return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + // Acquire the current value of the appropriate field + Object current = null; + Object bean = pageContext.findAttribute(name); + if (bean == null) + throw new JspException + (messages.getMessage("getter.bean", name)); + try { + current = BeanUtils.getProperty(bean, property); + if (current == null) + current = ""; + } catch (IllegalAccessException e) { + throw new JspException + (messages.getMessage("getter.access", property, name)); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + throw new JspException + (messages.getMessage("getter.result", + property, t.toString())); + } catch (NoSuchMethodException e) { + throw new JspException + (messages.getMessage("getter.method", property, name)); + } + + results.append(" value=\""); + results.append(this.value); + results.append("\""); + if (value.equals(current)) + results.append(" checked"); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java,v retrieving revision 1.3 diff -u -r1.3 ResetTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java 2001/04/18 01:31:15 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java + 2001/05/14 00:58:26 @@ -199,33 +199,14 @@ */ public int doEndTag() throws JspException { - // Acquire the label value we will be generating - String label = value; - if ((label == null) && (text != null)) - label = text; - if ((label == null) || (label.length() < 1)) - label = "Reset"; // Generate an HTML element StringBuffer results = new StringBuffer(); - results.append("<input type=\"reset\" name=\""); - results.append(name); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - results.append(label); - results.append("\""); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + results.append("<input type=\"reset\""); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Render this element to our writer @@ -233,6 +214,63 @@ // Evaluate the remainder of this page return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(name); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + // Acquire the label value we will be generating + String label = value; + if ((label == null) && (text != null)) + label = text; + if ((label == null) || (label.length() < 1)) + label = "Reset"; + + results.append(" value=\""); + results.append(label); + results.append("\""); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java,v retrieving revision 1.3 diff -u -r1.3 SelectTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java 2001/02/22 02:53:30 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java + 2001/05/14 00:58:28 @@ -242,29 +242,11 @@ // Create an appropriate "form" element based on our parameters StringBuffer results = new StringBuffer("<select"); - results.append(" name=\""); - results.append(property); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (multiple != null) { - results.append(" multiple"); - } - if (size != null) { - results.append(" size=\""); - results.append(size); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Print this field to our output writer @@ -274,37 +256,7 @@ pageContext.setAttribute(Constants.SELECT_KEY, this); // Calculate the match values we will actually be using - if (value != null) { - match = new String[1]; - match[0] = value; - } else { - Object bean = pageContext.findAttribute(name); - if (bean == null) { - JspException e = new JspException - (messages.getMessage("getter.bean", name)); - RequestUtils.saveException(pageContext, e); - throw e; - } - try { - match = BeanUtils.getArrayProperty(bean, property); - if (match == null) - match = new String[0]; - } catch (IllegalAccessException e) { - RequestUtils.saveException(pageContext, e); - throw new JspException - (messages.getMessage("getter.access", property, name)); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - RequestUtils.saveException(pageContext, t); - throw new JspException - (messages.getMessage("getter.result", - property, t.toString())); - } catch (NoSuchMethodException e) { - RequestUtils.saveException(pageContext, e); - throw new JspException - (messages.getMessage("getter.method", property, name)); - } - } + calculateMatchValue(); // Continue processing this page return (EVAL_BODY_TAG); @@ -356,6 +308,87 @@ } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + + if (multiple != null) { + results.append(" multiple"); + } + + results.append(prepareAttribute("size", size)); + results.append(prepareAttribute("tabindex", tabindex)); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Calculate the match values we will actually be using + * + * @exception JspException if a JSP exception has occurred + */ + protected void calculateMatchValue() throws JspException { + + // Calculate the match values we will actually be using + if (value != null) { + match = new String[1]; + match[0] = value; + } else { + Object bean = pageContext.findAttribute(name); + if (bean == null) { + JspException e = new JspException + (messages.getMessage("getter.bean", name)); + RequestUtils.saveException(pageContext, e); + throw e; + } + try { + match = BeanUtils.getArrayProperty(bean, property); + if (match == null) + match = new String[0]; + } catch (IllegalAccessException e) { + RequestUtils.saveException(pageContext, e); + throw new JspException + (messages.getMessage("getter.access", property, name)); + } catch (InvocationTargetException e) { + Throwable t = e.getTargetException(); + RequestUtils.saveException(pageContext, t); + throw new JspException + (messages.getMessage("getter.result", + property, t.toString())); + } catch (NoSuchMethodException e) { + RequestUtils.saveException(pageContext, e); + throw new JspException + (messages.getMessage("getter.method", property, name)); + } + } + + } /** * Release any acquired resources. Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v retrieving revision 1.3 diff -u -r1.3 SubmitTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java 2001/04/18 01:31:15 1.3 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java + 2001/05/14 00:58:29 @@ -129,7 +129,7 @@ * @param property The property name */ public void setProperty(String property) { - + this.property = property; } @@ -199,33 +199,13 @@ */ public int doEndTag() throws JspException { - // Acquire the label value we will be generating - String label = value; - if ((label == null) && (text != null)) - label = text; - if ((label == null) || (label.length() < 1)) - label = "Submit"; - // Generate an HTML element StringBuffer results = new StringBuffer(); - results.append("<input type=\"submit\" name=\""); - results.append(property); - results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - results.append(" value=\""); - results.append(label); - results.append("\""); - results.append(prepareEventHandlers()); - results.append(prepareStyles()); + results.append("<input type=\"submit\""); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + results.append(">"); // Render this element to our writer @@ -233,6 +213,63 @@ // Evaluate the remainder of this page return (EVAL_PAGE); + + } + + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + + prepareValue(results); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + + results.append(" name=\""); + results.append(property); + results.append("\""); + + } + + /** + * Prepares the value attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + + // Acquire the label value we will be generating + String label = value; + if ((label == null) && (text != null)) + label = text; + if ((label == null) || (label.trim().length() < 1)) + label = "Submit"; + + results.append(" value=\""); + results.append(label); + results.append("\""); } Index: d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java =================================================================== RCS file: /home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java,v retrieving revision 1.4 diff -u -r1.4 TextareaTag.java --- d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java 2001/04/18 23:51:32 1.4 +++ d:/project/jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java + 2001/05/14 00:58:30 @@ -113,32 +113,68 @@ // Create an appropriate "input" element based on our parameters StringBuffer results = new StringBuffer("<textarea"); + + // Prepare indvidual attributes for this element + prepareAttributes(results); + + results.append(">"); + + // Prepare the contents of the text area + prepareValue(results); + + results.append("</textarea>"); + + // Print this field to our output writer + ResponseUtils.write(pageContext, results.toString()); + + // Continue processing this page + return (EVAL_BODY_TAG); + + } + /** + * Prepares the individual attributes, appending them to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareAttributes(StringBuffer results) throws JspException { + + prepareName(results); + + results.append(prepareAttribute("accesskey", accesskey)); + results.append(prepareAttribute("tabindex", tabindex)); + results.append(prepareAttribute("cols", cols)); + results.append(prepareAttribute("rows", rows)); + + results.append(prepareEventHandlers()); + results.append(prepareStyles()); + + } + /** + * Prepares the name attribute, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareName(StringBuffer results) throws JspException { + results.append(" name=\""); results.append(property); results.append("\""); - if (accesskey != null) { - results.append(" accesskey=\""); - results.append(accesskey); - results.append("\""); - } - if (tabindex != null) { - results.append(" tabindex=\""); - results.append(tabindex); - results.append("\""); - } - if (cols != null) { - results.append(" cols=\""); - results.append(cols); - results.append("\""); - } - if (rows != null) { - results.append(" rows=\""); - results.append(rows); - results.append("\""); - } - results.append(prepareEventHandlers()); - results.append(prepareStyles()); - results.append(">"); + + } + + /** + * Prepares the contents of the text area, appending it to the the given + * StringBuffer. + * + * @param results The StringBuffer that output will be appended to. + * @exception JspException if a JSP exception has occurred + */ + protected void prepareValue(StringBuffer results) throws JspException { + if (value != null) { results.append(ResponseUtils.filter(value)); } else { @@ -164,16 +200,8 @@ (messages.getMessage("getter.method", property, name)); } } - results.append("</textarea>"); - - // Print this field to our output writer - ResponseUtils.write(pageContext, results.toString()); - // Continue processing this page - return (EVAL_BODY_TAG); - } - /** * Release any acquired resources. *****CVS exited normally with code 1*****