craigmcc 01/04/17 18:31:18 Modified: src/share/org/apache/struts/taglib/html ButtonTag.java CancelTag.java CheckboxTag.java LinkTag.java MultiboxTag.java RadioTag.java ResetTag.java SubmitTag.java Log: Improve the ability of the struts-html.tld tags to operate in containers that do not call doAfterBody() when a tag has no body, and/or do not allow access to the bodyContent property in the doEndTag() method. Revision Changes Path 1.3 +26 -17 jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java Index: ButtonTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ButtonTag.java 2001/01/08 21:36:03 1.2 +++ ButtonTag.java 2001/04/18 01:31:14 1.3 @@ -1,13 +1,13 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v 1.2 2001/01/08 21:36:03 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/01/08 21:36:03 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ButtonTag.java,v 1.3 2001/04/18 01:31:14 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/18 01:31:14 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] @@ -67,13 +67,14 @@ import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.JspWriter; +import org.apache.struts.util.ResponseUtils; /** * Renders an HTML BUTTON tag within the Struts framework. * * @author Don Clasen - * @version $Revision: 1.2 $ $Date: 2001/01/08 21:36:03 $ + * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:14 $ */ public class ButtonTag extends BaseHandlerTag { @@ -88,6 +89,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The value of the button label. */ protected String value = null; @@ -129,26 +136,33 @@ this.value = value; } + // --------------------------------------------------------- Public Methods + /** * Process the start of this tag. * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { + // Do nothing until doEndTag() is called + this.text = null; 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) && (bodyContent != null)) - label = bodyContent.getString().trim(); + if ((label == null) && (text != null)) + label = text; if ((label == null) || (label.trim().length() < 1)) label = "Click"; @@ -178,15 +192,9 @@ results.append(">"); // Render this element to our writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } - catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } - + ResponseUtils.write(pageContext, results.toString()); + + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -199,6 +207,7 @@ super.release(); property = null; + text = null; value = null; } 1.3 +72 -46 jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java Index: CancelTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- CancelTag.java 2001/01/08 21:36:04 1.2 +++ CancelTag.java 2001/04/18 01:31:14 1.3 @@ -1,13 +1,13 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java,v 1.2 2001/01/08 21:36:04 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/01/08 21:36:04 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CancelTag.java,v 1.3 2001/04/18 01:31:14 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/18 01:31:14 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] @@ -68,13 +68,14 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.JspWriter; import org.apache.struts.util.MessageResources; +import org.apache.struts.util.ResponseUtils; /** * Tag for input fields of type "cancel". * * @author Jeff Hutchinson - * @version $Revision: 1.2 $ $Date: 2001/01/08 21:36:04 $ + * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:14 $ */ public class CancelTag extends BaseHandlerTag { @@ -82,6 +83,7 @@ // ----------------------------------------------------- Instance Variables + /** * The message resources for this package. */ @@ -96,6 +98,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The value of the button label. */ protected String value = null; @@ -137,64 +145,81 @@ this.value = value; } + // --------------------------------------------------------- Public Methods + /** * Process the start of this tag. * @exception JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { + // Do nothing until doEndTag() is called + this.text = null; return (EVAL_BODY_TAG); + } + /** + * Save the associated label from the body content. + * + * @exception JspException if a JSP exception has occurred + */ + public int doAfterBody() throws JspException { + + if (bodyContent != null) { + String value = bodyContent.getString().trim(); + if (value.length() > 0) + text = value; + } + return (SKIP_BODY); + + } + + + /** * 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) && (bodyContent != null)) - label = bodyContent.getString().trim(); - 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()); - results.append(">"); - - // Render this element to our writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } - catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + // 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()); + results.append(">"); + + // Render this element to our writer + ResponseUtils.write(pageContext, results.toString()); - return (EVAL_PAGE); + // Evaluate the remainder of this page + return (EVAL_PAGE); } @@ -206,6 +231,7 @@ super.release(); property = Constants.CANCEL_PROPERTY; + text = null; value = null; } 1.4 +19 -6 jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java Index: CheckboxTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- CheckboxTag.java 2001/03/10 23:27:31 1.3 +++ CheckboxTag.java 2001/04/18 01:31:14 1.4 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v 1.3 2001/03/10 23:27:31 craigmcc Exp $ - * $Revision: 1.3 $ - * $Date: 2001/03/10 23:27:31 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/CheckboxTag.java,v 1.4 2001/04/18 01:31:14 craigmcc Exp $ + * $Revision: 1.4 $ + * $Date: 2001/04/18 01:31:14 $ * * ==================================================================== * @@ -76,7 +76,7 @@ * Tag for input fields of type "checkbox". * * @author Craig R. McClanahan - * @version $Revision: 1.3 $ $Date: 2001/03/10 23:27:31 $ + * @version $Revision: 1.4 $ $Date: 2001/04/18 01:31:14 $ */ public class CheckboxTag extends BaseHandlerTag { @@ -113,6 +113,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The server value for this option. */ protected String value = null; @@ -215,6 +221,7 @@ ResponseUtils.write(pageContext, results.toString()); // Continue processing this page + this.text = null; return (EVAL_BODY_TAG); } @@ -222,7 +229,7 @@ /** - * Optionally render the associated label from the body content. + * Save the associated label from the body content. * * @exception JspException if a JSP exception has occurred */ @@ -231,7 +238,7 @@ if (bodyContent != null) { String value = bodyContent.getString().trim(); if (value.length() > 0) - ResponseUtils.write(pageContext, value); + text = value; } return (SKIP_BODY); @@ -245,6 +252,11 @@ */ public int doEndTag() throws JspException { + // Render any description for this checkbox + if (text != null) + ResponseUtils.write(pageContext, text); + + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -258,6 +270,7 @@ super.release(); name = Constants.BEAN_KEY; property = null; + text = null; value = null; } 1.8 +29 -29 jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java Index: LinkTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- LinkTag.java 2001/04/03 18:06:19 1.7 +++ LinkTag.java 2001/04/18 01:31:15 1.8 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v 1.7 2001/04/03 18:06:19 craigmcc Exp $ - * $Revision: 1.7 $ - * $Date: 2001/04/03 18:06:19 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/LinkTag.java,v 1.8 2001/04/18 01:31:15 craigmcc Exp $ + * $Revision: 1.8 $ + * $Date: 2001/04/18 01:31:15 $ * * ==================================================================== * @@ -80,18 +80,28 @@ import org.apache.struts.util.MessageResources; import org.apache.struts.util.PropertyUtils; import org.apache.struts.util.RequestUtils; +import org.apache.struts.util.ResponseUtils; /** * Generate a URL-encoded hyperlink to the specified URI. * * @author Craig R. McClanahan - * @version $Revision: 1.7 $ $Date: 2001/04/03 18:06:19 $ + * @version $Revision: 1.8 $ $Date: 2001/04/18 01:31:15 $ */ public class LinkTag extends BaseHandlerTag { + // ----------------------------------------------------- Instance Variables + + + /** + * The body content of this tag (if any). + */ + protected String text = null; + + // ------------------------------------------------------------- Properties @@ -334,17 +344,10 @@ results.append(">"); // Print this element to our output writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } catch (IOException e) { - pageContext.setAttribute(Action.EXCEPTION_KEY, e, - PageContext.REQUEST_SCOPE); - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + ResponseUtils.write(pageContext, results.toString()); // Evaluate the body of this tag + this.text = null; return (EVAL_BODY_TAG); } @@ -352,20 +355,16 @@ /** - * Render the body content of this hyperlink. + * Save the associated label from the body content. * * @exception JspException if a JSP exception has occurred */ public int doAfterBody() throws JspException { if (bodyContent != null) { - JspWriter writer = bodyContent.getEnclosingWriter(); - try { - writer.print(bodyContent.getString().trim()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + String value = bodyContent.getString().trim(); + if (value.length() > 0) + text = value; } return (SKIP_BODY); @@ -379,16 +378,16 @@ */ public int doEndTag() throws JspException { + // Prepare the textual content and ending element of this hyperlink + StringBuffer results = new StringBuffer(); + if (text != null) + results.append(text); + results.append("</a>"); - // Print the ending element to our output writer - JspWriter writer = pageContext.getOut(); - try { - writer.print("</a>"); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + // Render the remainder to the output stream + ResponseUtils.write(pageContext, results.toString()); + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -413,6 +412,7 @@ property = null; scope = null; target = null; + text = null; transaction = false; } 1.5 +6 -11 jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java Index: MultiboxTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- MultiboxTag.java 2001/04/03 19:23:15 1.4 +++ MultiboxTag.java 2001/04/18 01:31:15 1.5 @@ -1,7 +1,7 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java,v 1.4 2001/04/03 19:23:15 craigmcc Exp $ - * $Revision: 1.4 $ - * $Date: 2001/04/03 19:23:15 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/MultiboxTag.java,v 1.5 2001/04/18 01:31:15 craigmcc Exp $ + * $Revision: 1.5 $ + * $Date: 2001/04/18 01:31:15 $ * * ==================================================================== * @@ -83,7 +83,7 @@ * * @author Ralph Schaer * @author Craig R. McClanahan - * @version $Revision: 1.4 $ $Date: 2001/04/03 19:23:15 $ + * @version $Revision: 1.5 $ $Date: 2001/04/18 01:31:15 $ */ public class MultiboxTag extends BaseHandlerTag { @@ -191,6 +191,7 @@ public int doStartTag() throws JspException { // Defer processing until the end of this tag is encountered + this.constant = null; return (EVAL_BODY_TAG); } @@ -281,13 +282,7 @@ results.append(">"); // Render this element to our response - JspWriter writer = pageContext.getOut(); - try { - writer.println(results.toString()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + ResponseUtils.write(pageContext, results.toString()); // Continue evaluating this page return (EVAL_PAGE); 1.3 +37 -24 jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java Index: RadioTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- RadioTag.java 2001/01/08 21:36:09 1.2 +++ RadioTag.java 2001/04/18 01:31:15 1.3 @@ -1,13 +1,13 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v 1.2 2001/01/08 21:36:09 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/01/08 21:36:09 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/RadioTag.java,v 1.3 2001/04/18 01:31:15 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/18 01:31:15 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] @@ -70,13 +70,14 @@ import javax.servlet.jsp.JspWriter; import org.apache.struts.util.BeanUtils; import org.apache.struts.util.MessageResources; +import org.apache.struts.util.ResponseUtils; /** * Tag for input fields of type "radio". * * @author Craig R. McClanahan - * @version $Revision: 1.2 $ $Date: 2001/01/08 21:36:09 $ + * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:15 $ */ public class RadioTag extends BaseHandlerTag { @@ -113,6 +114,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The server value for this option. */ protected String value = null; @@ -223,39 +230,44 @@ results.append(">"); // Print this field to our output writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + ResponseUtils.write(pageContext, results.toString()); // Continue processing this page + this.text = null; return (EVAL_BODY_TAG); } /** + * Save the associated label from the body content. + * + * @exception JspException if a JSP exception has occurred + */ + public int doAfterBody() throws JspException { + + if (bodyContent != null) { + String value = bodyContent.getString().trim(); + if (value.length() > 0) + text = value; + } + return (SKIP_BODY); + + } + + + /** * Optionally render the associated label from the body content. * * @exception JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { - - if (bodyContent == null) - return (EVAL_PAGE); - JspWriter writer = pageContext.getOut(); - try { - writer.println(bodyContent.getString().trim()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + // Render any description for this radio button + if (text != null) + ResponseUtils.write(pageContext, text); - // Continue evaluating this page + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -269,6 +281,7 @@ super.release(); name = Constants.BEAN_KEY; property = null; + text = null; value = null; } 1.3 +36 -15 jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java Index: ResetTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ResetTag.java 2001/01/08 21:36:10 1.2 +++ ResetTag.java 2001/04/18 01:31:15 1.3 @@ -1,13 +1,13 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java,v 1.2 2001/01/08 21:36:10 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/01/08 21:36:10 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ResetTag.java,v 1.3 2001/04/18 01:31:15 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/18 01:31:15 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] @@ -69,13 +69,14 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.JspWriter; import org.apache.struts.util.MessageResources; +import org.apache.struts.util.ResponseUtils; /** * Tag for input fields of type "reset". * * @author Craig R. McClanahan - * @version $Revision: 1.2 $ $Date: 2001/01/08 21:36:10 $ + * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:15 $ */ public class ResetTag extends BaseHandlerTag { @@ -98,6 +99,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The value of the button label. */ protected String value = null; @@ -161,6 +168,7 @@ public int doStartTag() throws JspException { // Do nothing until doEndTag() is called + this.text = null; return (EVAL_BODY_TAG); } @@ -168,6 +176,23 @@ /** + * Save the associated label from the body content. + * + * @exception JspException if a JSP exception has occurred + */ + public int doAfterBody() throws JspException { + + if (bodyContent != null) { + String value = bodyContent.getString().trim(); + if (value.length() > 0) + text = value; + } + return (SKIP_BODY); + + } + + + /** * Process the end of this tag. * * @exception JspException if a JSP exception has occurred @@ -176,8 +201,8 @@ // Acquire the label value we will be generating String label = value; - if ((label == null) && (bodyContent != null)) - label = bodyContent.getString().trim(); + if ((label == null) && (text != null)) + label = text; if ((label == null) || (label.length() < 1)) label = "Reset"; @@ -204,14 +229,9 @@ results.append(">"); // Render this element to our writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + ResponseUtils.write(pageContext, results.toString()); + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -224,6 +244,7 @@ super.release(); name = "reset"; + text = null; value = null; } 1.3 +36 -15 jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java Index: SubmitTag.java =================================================================== RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- SubmitTag.java 2001/01/08 21:36:11 1.2 +++ SubmitTag.java 2001/04/18 01:31:15 1.3 @@ -1,13 +1,13 @@ /* - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v 1.2 2001/01/08 21:36:11 craigmcc Exp $ - * $Revision: 1.2 $ - * $Date: 2001/01/08 21:36:11 $ + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SubmitTag.java,v 1.3 2001/04/18 01:31:15 craigmcc Exp $ + * $Revision: 1.3 $ + * $Date: 2001/04/18 01:31:15 $ * * ==================================================================== * * The Apache Software License, Version 1.1 * - * Copyright (c) 1999 The Apache Software Foundation. All rights + * Copyright (c) 1999-2001 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -29,7 +29,7 @@ * Alternately, this acknowlegement may appear in the software itself, * if and wherever such third-party acknowlegements normally appear. * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * 4. The names "The Jakarta Project", "Struts", and "Apache Software * Foundation" must not be used to endorse or promote products derived * from this software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] @@ -69,13 +69,14 @@ import javax.servlet.jsp.PageContext; import javax.servlet.jsp.JspWriter; import org.apache.struts.util.MessageResources; +import org.apache.struts.util.ResponseUtils; /** * Tag for input fields of type "submit". * * @author Craig R. McClanahan - * @version $Revision: 1.2 $ $Date: 2001/01/08 21:36:11 $ + * @version $Revision: 1.3 $ $Date: 2001/04/18 01:31:15 $ */ public class SubmitTag extends BaseHandlerTag { @@ -98,6 +99,12 @@ /** + * The body content of this tag (if any). + */ + protected String text = null; + + + /** * The value of the button label. */ protected String value = null; @@ -161,6 +168,7 @@ public int doStartTag() throws JspException { // Do nothing until doEndTag() is called + this.text = null; return (EVAL_BODY_TAG); } @@ -168,6 +176,23 @@ /** + * Save the associated label from the body content. + * + * @exception JspException if a JSP exception has occurred + */ + public int doAfterBody() throws JspException { + + if (bodyContent != null) { + String value = bodyContent.getString().trim(); + if (value.length() > 0) + text = value; + } + return (SKIP_BODY); + + } + + + /** * Process the end of this tag. * * @exception JspException if a JSP exception has occurred @@ -176,8 +201,8 @@ // Acquire the label value we will be generating String label = value; - if ((label == null) && (bodyContent != null)) - label = bodyContent.getString().trim(); + if ((label == null) && (text != null)) + label = text; if ((label == null) || (label.length() < 1)) label = "Submit"; @@ -204,14 +229,9 @@ results.append(">"); // Render this element to our writer - JspWriter writer = pageContext.getOut(); - try { - writer.print(results.toString()); - } catch (IOException e) { - throw new JspException - (messages.getMessage("common.io", e.toString())); - } + ResponseUtils.write(pageContext, results.toString()); + // Evaluate the remainder of this page return (EVAL_PAGE); } @@ -224,6 +244,7 @@ super.release(); property = "submit"; + text = null; value = null; }