You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by ni...@apache.org on 2004/09/23 02:34:15 UTC

cvs commit: jakarta-struts/web/test/test/org/apache/struts/taglib/html TestCancelTag1.jsp TestCancelTag2.jsp

niallp      2004/09/22 17:34:15

  Modified:    src/share/org/apache/struts/taglib/html BaseFieldTag.java
                        BaseHandlerTag.java BaseInputTag.java
                        ButtonTag.java CancelTag.java CheckboxTag.java
                        FrameTag.java ImageTag.java ImgTag.java
                        LinkTag.java MultiboxTag.java RadioTag.java
                        ResetTag.java SelectTag.java SubmitTag.java
                        TextareaTag.java
               web/test/test/org/apache/struts/taglib/html
                        TestCancelTag1.jsp TestCancelTag2.jsp
  Log:
  Refactor some of the HTML tags make extending them easier
  
  * added prepareOtherAttributes() method
  * added prepareName() method
  * use getters rather than instance variables
  * Refactored SubmitTag
  * ButtonTag, CancelTag and ResetTag now inherit from SubmitTag
  
  Revision  Changes    Path
  1.26      +24 -58    jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java
  
  Index: BaseFieldTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseFieldTag.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- BaseFieldTag.java	14 Mar 2004 06:23:46 -0000	1.25
  +++ BaseFieldTag.java	23 Sep 2004 00:34:14 -0000	1.26
  @@ -51,19 +51,6 @@
       }
   
       /**
  -     * The name of the bean containing our underlying property.
  -     */
  -    protected String name = Constants.BEAN_KEY;
  -
  -    public String getName() {
  -        return (this.name);
  -    }
  -
  -    public void setName(String name) {
  -        this.name = name;
  -    }
  -
  -    /**
        * The "redisplay contents" flag (used only on <code>password</code>).
        */
       protected boolean redisplay = true;
  @@ -105,45 +92,28 @@
        * @since Struts 1.2
        */
       protected String renderInputElement() throws JspException {
  -        StringBuffer results = new StringBuffer("<input type=\"");
  -        results.append(this.type);
  -        results.append("\" name=\"");
  -
  -        if (indexed) {
  -            this.prepareIndex(results, 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("\"");
  -        }
  +        StringBuffer results = new StringBuffer("<input");
   
  -        if (cols != null) {
  -            results.append(" size=\"");
  -            results.append(cols);
  -            results.append("\"");
  -        }
  +        prepareAttribute(results, "type", this.type);
  +        prepareName(results);
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "accept", getAccept());
  +        prepareAttribute(results, "maxlength", getMaxlength());
  +        prepareAttribute(results, "size", getCols());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +        prepareValue(results);
  +        results.append(this.prepareEventHandlers());
  +        results.append(this.prepareStyles());
  +        prepareOtherAttributes(results);
  +        results.append(this.getElementClose());
  +        return results.toString();
  +    }
   
  -        if (tabindex != null) {
  -            results.append(" tabindex=\"");
  -            results.append(tabindex);
  -            results.append("\"");
  -        }
  +    /**
  +     * Render the value element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareValue(StringBuffer results) throws JspException {
   
           results.append(" value=\"");
           if (value != null) {
  @@ -157,11 +127,7 @@
           }
   
           results.append('"');
  -        results.append(this.prepareEventHandlers());
  -        results.append(this.prepareStyles());
  -        results.append(this.getElementClose());
   
  -        return results.toString();
       }
       
       /**
  
  
  
  1.37      +50 -108   jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java
  
  Index: BaseHandlerTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseHandlerTag.java,v
  retrieving revision 1.36
  retrieving revision 1.37
  diff -u -r1.36 -r1.37
  --- BaseHandlerTag.java	14 Mar 2004 06:23:46 -0000	1.36
  +++ BaseHandlerTag.java	23 Sep 2004 00:34:14 -0000	1.37
  @@ -660,36 +660,17 @@
        * @exception JspException if invalid attributes are specified
        */
       protected String prepareStyles() throws JspException {
  -        String value = null;
  +
           StringBuffer styles = new StringBuffer();
  -        if (getStyle() != null) {
  -            styles.append(" style=\"");
  -            styles.append(getStyle());
  -            styles.append("\"");
  -        }
  -        if (getStyleClass() != null) {
  -            styles.append(" class=\"");
  -            styles.append(getStyleClass());
  -            styles.append("\"");
  -        }
  -        if (getStyleId() != null) {
  -            styles.append(" id=\"");
  -            styles.append(getStyleId());
  -            styles.append("\"");
  -        }
  -        value = message(this.getTitle(), this.getTitleKey());
  -        if (value != null) {
  -            styles.append(" title=\"");
  -            styles.append(value);
  -            styles.append("\"");
  -        }
  -        value = message(this.getAlt(), this.getAltKey());
  -        if (value != null) {
  -            styles.append(" alt=\"");
  -            styles.append(value);
  -            styles.append("\"");
  -        }
  +
  +        prepareAttribute(styles , "style", getStyle());
  +        prepareAttribute(styles , "class", getStyleClass());
  +        prepareAttribute(styles , "id", getStyleId());
  +        prepareAttribute(styles , "title", message(getTitle(), getTitleKey()));
  +        prepareAttribute(styles , "alt", message(getAlt(), getAltKey()));
  +
           return styles.toString();
  +
       }
   
       /**
  @@ -711,47 +692,15 @@
        * @param handlers The StringBuffer that output will be appended to.
        */
       protected void prepareMouseEvents(StringBuffer handlers) {
  -        if (getOnclick() != null) {
  -            handlers.append(" onclick=\"");
  -            handlers.append(getOnclick());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOndblclick() != null) {
  -            handlers.append(" ondblclick=\"");
  -            handlers.append(getOndblclick());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOnmouseover() != null) {
  -            handlers.append(" onmouseover=\"");
  -            handlers.append(getOnmouseover());
  -            handlers.append("\"");
  -        }
   
  -        if (getOnmouseout() != null) {
  -            handlers.append(" onmouseout=\"");
  -            handlers.append(getOnmouseout());
  -            handlers.append("\"");
  -        }
  +        prepareAttribute(handlers, "onclick", getOnclick());
  +        prepareAttribute(handlers, "ondblclick", getOndblclick());
  +        prepareAttribute(handlers, "onmouseover", getOnmouseover());
  +        prepareAttribute(handlers, "onmouseout", getOnmouseout());
  +        prepareAttribute(handlers, "onmousemove", getOnmousemove());
  +        prepareAttribute(handlers, "onmousedown", getOnmousedown());
  +        prepareAttribute(handlers, "onmouseup", getOnmouseup());
   
  -        if (getOnmousemove() != null) {
  -            handlers.append(" onmousemove=\"");
  -            handlers.append(getOnmousemove());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOnmousedown() != null) {
  -            handlers.append(" onmousedown=\"");
  -            handlers.append(getOnmousedown());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOnmouseup() != null) {
  -            handlers.append(" onmouseup=\"");
  -            handlers.append(getOnmouseup());
  -            handlers.append("\"");
  -        }
       }
   
       /**
  @@ -761,23 +710,10 @@
        */
       protected void prepareKeyEvents(StringBuffer handlers) {
   
  -        if (getOnkeydown() != null) {
  -            handlers.append(" onkeydown=\"");
  -            handlers.append(getOnkeydown());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOnkeyup() != null) {
  -            handlers.append(" onkeyup=\"");
  -            handlers.append(getOnkeyup());
  -            handlers.append("\"");
  -        }
  +        prepareAttribute(handlers, "onkeydown", getOnkeydown());
  +        prepareAttribute(handlers, "onkeyup", getOnkeyup());
  +        prepareAttribute(handlers, "onkeypress", getOnkeypress());
   
  -        if (getOnkeypress() != null) {
  -            handlers.append(" onkeypress=\"");
  -            handlers.append(getOnkeypress());
  -            handlers.append("\"");
  -        }
       }
   
       /**
  @@ -787,17 +723,9 @@
        */
       protected void prepareTextEvents(StringBuffer handlers) {
   
  -        if (getOnselect() != null) {
  -            handlers.append(" onselect=\"");
  -            handlers.append(getOnselect());
  -            handlers.append("\"");
  -        }
  +        prepareAttribute(handlers, "onselect", getOnselect());
  +        prepareAttribute(handlers, "onchange", getOnchange());
   
  -        if (getOnchange() != null) {
  -            handlers.append(" onchange=\"");
  -            handlers.append(getOnchange());
  -            handlers.append("\"");
  -        }
       }
   
       /**
  @@ -807,17 +735,8 @@
        */
       protected void prepareFocusEvents(StringBuffer handlers) {
   
  -        if (getOnblur() != null) {
  -            handlers.append(" onblur=\"");
  -            handlers.append(getOnblur());
  -            handlers.append("\"");
  -        }
  -
  -        if (getOnfocus() != null) {
  -            handlers.append(" onfocus=\"");
  -            handlers.append(getOnfocus());
  -            handlers.append("\"");
  -        }
  +        prepareAttribute(handlers, "onblur", getOnblur());
  +        prepareAttribute(handlers, "onfocus", getOnfocus());
   
           if (getDisabled()) {
               handlers.append(" disabled=\"disabled\"");
  @@ -827,6 +746,29 @@
               handlers.append(" readonly=\"readonly\"");
           }
   
  +    }
  +
  +    /**
  +     * 'Hook' to enable tags to be extended and 
  +     *  additional attributes added.
  +     * @param handlers The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareOtherAttributes(StringBuffer handlers) {
  +    }
  +
  +    /**
  +     * Prepares an attribute if the value is not null, appending it to the the given
  +     * StringBuffer.
  +     * @param handlers The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareAttribute(StringBuffer handlers, String name, Object value) {
  +        if (value != null) {
  +            handlers.append(" ");
  +            handlers.append(name);
  +            handlers.append("=\"");
  +            handlers.append(value);
  +            handlers.append("\"");
  +        }
       }
   
       /**
  
  
  
  1.7       +35 -4     jakarta-struts/src/share/org/apache/struts/taglib/html/BaseInputTag.java
  
  Index: BaseInputTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/BaseInputTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BaseInputTag.java	14 Mar 2004 06:23:46 -0000	1.6
  +++ BaseInputTag.java	23 Sep 2004 00:34:14 -0000	1.7
  @@ -65,8 +65,21 @@
        */
       protected String value = null;
   
  +    /**
  +     * The name of the bean containing our underlying property.
  +     */
  +    protected String name = Constants.BEAN_KEY;
  +
       // ------------------------------------------------------------- Properties
   
  +    public String getName() {
  +        return (this.name);
  +    }
  +
  +    public void setName(String name) {
  +        this.name = name;
  +    }
  +
       /**
        * Return the number of columns for this field.
        */
  @@ -213,11 +226,29 @@
       }
   
       /**
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareName(StringBuffer results) throws JspException {
  +
  +        if (property != null) {
  +            results.append(" name=\"");
  +            // * @since Struts 1.1
  +            if( indexed )
  +                prepareIndex(results, name);
  +            results.append(property);
  +            results.append("\"");
  +        }
  +
  +    }
  +
  +    /**
        * Release any acquired resources.
        */
       public void release() {
   
           super.release();
  +        name = Constants.BEAN_KEY;
           cols = null;
           maxlength = null;
           property = null;
  
  
  
  1.19      +13 -155   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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- ButtonTag.java	14 Mar 2004 06:23:46 -0000	1.18
  +++ ButtonTag.java	23 Sep 2004 00:34:14 -0000	1.19
  @@ -20,169 +20,27 @@
   
   package org.apache.struts.taglib.html;
   
  -import javax.servlet.jsp.JspException;
  -
  -import org.apache.struts.taglib.TagUtils;
  -
   /**
    * Renders an HTML BUTTON tag within the Struts framework.
    *
    * @version $Revision$ $Date$
    */
  -public class ButtonTag extends BaseHandlerTag {
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /**
  -     * The property name of the generated button.
  -     */
  -    protected String property = null;
  -
  +public class ButtonTag extends SubmitTag {
   
       /**
  -     * The body content of this tag (if any).
  +     * Render the openning element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    protected String text = null;
  -
  -
  -    /**
  -     * The value of the button label.
  -     */
  -    protected String value = null;
  -
  -
  -    // ------------------------------------------------------------- Properties
  -
  -
  -    /**
  -     * Return the property name.
  -     */
  -    public String getProperty() {
  -        return (property);
  -    }
  -
  -    /**
  -     * Set the property name.
  -     *
  -     * @param property The property name
  -     */
  -    public void setProperty(String property) {
  -        this.property = property;
  +    protected String getElementOpen() {
  +        return "<input type=\"button\"";
       }
   
  -
       /**
  -     * Return the label value.
  +     * Return the default value
  +     * @param defaultValue The default value if none supplied
        */
  -    public String getValue() {
  -        return (value);
  -    }
  -
  -
  -    /**
  -     * Set the label value.
  -     * @param value The label value
  -     */
  -    public void setValue(String value) {
  -        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 (if any).
  -     * @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.
  -     * <p>
  -     * Support for indexed property since Struts 1.1
  -     * @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);
  -            // * @since Struts 1.1
  -            if( indexed )
  -                prepareIndex( results, null );
  -            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(getElementClose());
  -
  -        // Render this element to our writer
  -        TagUtils.getInstance().write(pageContext, results.toString());
  -
  -        // Evaluate the remainder of this page
  -        return (EVAL_PAGE);
  -
  -    }
  -
  -
  -    /**
  -     * Release any acquired resources.
  -     */
  -    public void release() {
  -
  -        super.release();
  -        property = null;
  -        text = null;
  -        value = null;
  -
  +    protected String getDefaultValue() {
  +        return "Click";
       }
   
   
  
  
  
  1.17      +28 -143   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.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CancelTag.java	14 Mar 2004 06:23:46 -0000	1.16
  +++ CancelTag.java	23 Sep 2004 00:34:14 -0000	1.17
  @@ -21,182 +21,67 @@
   
   package org.apache.struts.taglib.html;
   
  -
  -import javax.servlet.jsp.JspException;
  -
  -import org.apache.struts.taglib.TagUtils;
  -import org.apache.struts.util.MessageResources;
  -
  -
   /**
    * Tag for input fields of type "cancel".
    *
    * @version $Revision$ $Date$
    */
   
  -public class CancelTag extends BaseHandlerTag {
  -
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    /**
  -     * The message resources for this package.
  -     */
  -    protected static MessageResources messages =
  -     MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
  -
  -
  -    /**
  -     * The property name of the generated button.
  -     */
  -    protected String property = Constants.CANCEL_PROPERTY;
  -
  -
  -    /**
  -     * The body content of this tag (if any).
  -     */
  -    protected String text = null;
  -
  -
  -    /**
  -     * The value of the button label.
  -     */
  -    protected String value = null;
  +public class CancelTag extends SubmitTag {
   
   
       // ------------------------------------------------------------- Properties
   
   
  -    /**
  -     * Return the property name.
  -     */
  -    public String getProperty() {
  -        return (property);
  +    /** Returns the onClick event handler. */
  +    public String getOnclick() {
  +        return super.getOnclick() == null ? "bCancel=true;"
  +                               : super.getOnclick();
       }
   
  -    /**
  -     * Set the property name.
  -     *
  -     * @param property The property name
  -     */
  -    public void setProperty(String property) {
  -        this.property = property;
  -    }
  +    // --------------------------------------------------------- Constructor
   
  +    public CancelTag() {
   
  -    /**
  -     * Return the label value.
  -     */
  -    public String getValue() {
  -        return (value);
  -    }
  -
  +        super();
  +        property = Constants.CANCEL_PROPERTY;
   
  -    /**
  -     * Set the label value.
  -     * @param value The label value
  -     */
  -    public void setValue(String value) {
  -        this.value = value;
       }
   
  -
  -    // --------------------------------------------------------- Public Methods
  -
  +    // --------------------------------------------------------- Protected Methods
   
       /**
  -     * Process the start of this tag.
  -     * @exception JspException if a JSP exception has occurred
  +     * Render the openning element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    public int doStartTag() throws JspException {
  -
  -        // Do nothing until doEndTag() is called
  -        this.text = null;
  -        return (EVAL_BODY_TAG);
  -
  +    protected String getElementOpen() {
  +        return "<input type=\"submit\"";
       }
   
  -
       /**
  -     * Save the associated label from the body content.
  -     *
  -     * @exception JspException if a JSP exception has occurred
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    public int doAfterBody() throws JspException {
  -
  -        if (bodyContent != null) {
  -            String value = bodyContent.getString().trim();
  -            if (value.length() > 0)
  -                text = value;
  -        }
  -        return (SKIP_BODY);
  -
  +    protected void prepareName(StringBuffer results) {
  +        prepareAttribute(results, "name", property);
       }
   
  -
       /**
  -     * Process the end of this tag.
  -     * @exception JspException if a JSP exception has occurred
  +     * Return the default value
  +     * @param defaultValue The default value if none supplied
        */
  -    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());
  -        
  -        // if no onclick event was provided, put in the cancel script
  -        if(results.toString().indexOf("onclick=")==-1){
  -          results.append(" onclick=\"bCancel=true;\"");
  -        }
  -        
  -        results.append(getElementClose());
  -
  -        // Render this element to our writer
  -        TagUtils.getInstance().write(pageContext, results.toString());
  -
  -        // Evaluate the remainder of this page
  -        return (EVAL_PAGE);
  -
  +    protected String getDefaultValue() {
  +        return "Cancel";
       }
   
  -
       /**
        * Release any acquired resources.
        */
       public void release() {
   
  -	super.release();
  -	property = Constants.CANCEL_PROPERTY;
  -        text = null;
  -	value = null;
  +        super.release();
  +        property = Constants.CANCEL_PROPERTY;
   
       }
  -
   
   }
  
  
  
  1.25      +30 -37    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- CheckboxTag.java	14 Mar 2004 06:23:46 -0000	1.24
  +++ CheckboxTag.java	23 Sep 2004 00:34:14 -0000	1.25
  @@ -95,7 +95,7 @@
        */
       public String getValue() {
   
  -        return (this.value);
  +        return value == null ? "on" : value;
   
       }
   
  @@ -123,42 +123,18 @@
   
           // Create an appropriate "input" element based on our parameters
           StringBuffer results = new StringBuffer("<input type=\"checkbox\"");
  -        results.append(" name=\"");
  -
  -        if (indexed) {
  -            prepareIndex(results, 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);
  +        prepareName(results);
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +
  +        prepareAttribute(results, "value", getValue());
  +        if (isChecked()) {
  +            results.append(" checked=\"checked\"");
           }
   
  -        results.append("\"");
  -        
  -		if (this.isChecked()) {
  -			results.append(" checked=\"checked\"");
  -		}
  -
           results.append(prepareEventHandlers());
           results.append(prepareStyles());
  +        prepareOtherAttributes(results);
           results.append(getElementClose());
   
           // Print this field to our output writer
  @@ -226,6 +202,23 @@
   
           // Evaluate the remainder of this page
           return (EVAL_PAGE);
  +
  +    }
  +
  +    /**
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareName(StringBuffer results) throws JspException {
  +
  +        if (property != null) {
  +            results.append(" name=\"");
  +            // * @since Struts 1.1
  +            if( indexed )
  +                prepareIndex(results, name);
  +            results.append(property);
  +            results.append("\"");
  +        }
   
       }
   
  
  
  
  1.14      +15 -38    jakarta-struts/src/share/org/apache/struts/taglib/html/FrameTag.java
  
  Index: FrameTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/FrameTag.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- FrameTag.java	14 Mar 2004 06:23:46 -0000	1.13
  +++ FrameTag.java	23 Sep 2004 00:34:14 -0000	1.14
  @@ -159,44 +159,21 @@
       public int doStartTag() throws JspException {
   
       // Print this element to our output writer
  -        StringBuffer results = new StringBuffer("<frame ");
  -        results.append("src=\"");
  -        results.append(calculateURL());
  -        results.append("\"");
  -        if (frameName != null) {
  -            results.append(" name=\"");
  -            results.append(frameName);
  -            results.append("\"");
  -        }
  +        StringBuffer results = new StringBuffer("<frame");
  +
  +        prepareAttribute(results, "src", calculateURL());
  +        prepareAttribute(results, "name", getFrameName());
  +
           if (noresize) {
               results.append(" noresize=\"noresize\"");
           }
  -        if (scrolling != null) {
  -            results.append(" scrolling=\"");
  -            results.append(scrolling);
  -            results.append("\"");
  -        }
  -        if (marginheight != null) {
  -            results.append(" marginheight=\"");
  -            results.append(marginheight);
  -            results.append("\"");
  -        }
  -        if (marginwidth != null) {
  -            results.append(" marginwidth=\"");
  -            results.append(marginwidth);
  -            results.append("\"");
  -        }
  -        if (frameborder != null) {
  -            results.append(" frameborder=\"");
  -            results.append(frameborder);
  -            results.append("\"");
  -        }
  -        if (longdesc != null) {
  -            results.append(" longdesc=\"");
  -            results.append(longdesc);
  -            results.append("\"");
  -        }
  +        prepareAttribute(results, "scrolling", getScrolling());
  +        prepareAttribute(results, "marginheight", getMarginheight());
  +        prepareAttribute(results, "marginwidth", getMarginwidth());
  +        prepareAttribute(results, "frameborder", getFrameborder());
  +        prepareAttribute(results, "longdesc", getLongdesc());
           results.append(prepareStyles());
  +        prepareOtherAttributes(results);
           results.append(getElementClose());
           TagUtils.getInstance().write(pageContext,results.toString());
   
  
  
  
  1.32      +29 -89    jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java
  
  Index: ImageTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ImageTag.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- ImageTag.java	14 Mar 2004 06:23:46 -0000	1.31
  +++ ImageTag.java	23 Sep 2004 00:34:14 -0000	1.32
  @@ -104,21 +104,6 @@
           this.pageKey = pageKey;
       }
   
  -
  -    /**
  -     * The name attribute for the image button.
  -     */
  -    protected String property = "";
  -
  -    public String getProperty() {
  -        return (this.property);
  -    }
  -
  -    public void setProperty(String property) {
  -        this.property = property;
  -    }
  -
  -
       /**
        * The URL of this image.
        */
  @@ -147,85 +132,40 @@
       }
   
   
  -    // --------------------------------------------------------- Public Methods
  +    // --------------------------------------------------------- Constructor
  +
  +    public ImageTag() {
  +        super();
  +        property = ""; 
  +    }
   
  +    // --------------------------------------------------------- Protected Methods
   
       /**
  -     * Process the start of this tag.
  -     *
  -     * @exception JspException if a JSP exception has occurred
  +     * Render the openning element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    public int doStartTag() throws JspException {
  -
  -        return (EVAL_BODY_TAG);
  -
  +    protected String getElementOpen() {
  +        return "<input type=\"image\"";
       }
   
  -
  -
       /**
  -     * Process the end of this tag.
  -     * [Indexed property since Struts 1.1]
  -     *
  -     * @exception JspException if a JSP exception has occurred
  +     * Render the button attributes
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    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\"");
  -        if (property != null) {
  -            results.append(" name=\"");
  -            results.append(property);
  -
  -            if (indexed) {
  -                prepareIndex(results, null);
  -            }
  -            results.append("\"");
  -        }
  -        
  -        tmp = src();
  +    protected void prepareButtonAttributes(StringBuffer results)
  +                      throws JspException {
  +        String tmp = src();
           if (tmp != null) {
  -            results.append(" src=\"");
  -            results.append(response.encodeURL(tmp));
  -            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 (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(getElementClose());
  -
  -        TagUtils.getInstance().write(pageContext, results.toString());
  -
  -        return (EVAL_PAGE);
  -
  +            HttpServletResponse response =
  +                (HttpServletResponse) pageContext.getResponse();
  +            prepareAttribute(results, "src", response.encodeURL(tmp));
  +        }
  +        prepareAttribute(results, "align", getAlign());
  +        prepareAttribute(results, "border", getBorder());
  +        prepareAttribute(results, "value", getValue());
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
       }
   
   
  
  
  
  1.42      +17 -55    jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java
  
  Index: ImgTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- ImgTag.java	24 Aug 2004 22:53:35 -0000	1.41
  +++ ImgTag.java	23 Sep 2004 00:34:14 -0000	1.42
  @@ -436,63 +436,25 @@
           String tmp = src();
           String srcurl = url(tmp);
           if (srcurl != null) {
  -            results.append(" src=\"");
  -            results.append(response.encodeURL(srcurl));
  -            results.append("\"");
  +            prepareAttribute(results, "src", response.encodeURL(srcurl));
           }
           String lowsrcurl = url(this.lowsrc);
           if (lowsrcurl != null) {
  -            results.append(" lowsrc=\"");
  -            results.append(response.encodeURL(lowsrcurl));
  -            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("\"");
  +            prepareAttribute(results, "lowsrcurl", response.encodeURL(lowsrcurl));
           }
  +
  +        prepareAttribute(results, "name", getImageName());
  +        prepareAttribute(results, "height", getHeight());
  +        prepareAttribute(results, "width", getWidth());
  +        prepareAttribute(results, "align", getAlign());
  +        prepareAttribute(results, "border", getBorder());
  +        prepareAttribute(results, "hspace", getHspace());
  +        prepareAttribute(results, "vspace", getVspace());
  +        prepareAttribute(results, "ismap", getIsmap());
  +        prepareAttribute(results, "usemap", getUsemap());
           results.append(prepareStyles());
           results.append(prepareEventHandlers());
  +        prepareOtherAttributes(results);
           results.append(getElementClose());
   
           TagUtils.getInstance().write(pageContext, results.toString());
  
  
  
  1.39      +13 -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.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- LinkTag.java	1 Aug 2004 03:00:28 -0000	1.38
  +++ LinkTag.java	23 Sep 2004 00:34:14 -0000	1.39
  @@ -322,35 +322,19 @@
           StringBuffer results = new StringBuffer("<a");
   
           // Special case for name anchors
  -        if (linkName != null) {
  -            results.append(" name=\"");
  -            results.append(linkName);
  -            results.append("\"");            
  -        }
  +        prepareAttribute(results, "name", getLinkName());
  +
           // * @since Struts 1.1
  -        if (linkName == null || forward != null  || href != null ||
  -            page != null || action != null) {
  -            results.append(" href=\"");
  -            results.append(calculateURL());
  -            results.append("\"");
  -        }
  -        if (target != null) {
  -            results.append(" target=\"");
  -            results.append(target);
  -            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 (getLinkName() == null || getForward() != null  || getHref() != null ||
  +            getPage() != null || getAction() != null) {
  +            prepareAttribute(results, "href", calculateURL());
           }
  +        prepareAttribute(results, "target", getTarget());
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
           results.append(prepareStyles());
           results.append(prepareEventHandlers());
  +        prepareOtherAttributes(results);
           results.append(">");
   
           TagUtils.getInstance().write(pageContext, results.toString());
  
  
  
  1.26      +40 -28    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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- MultiboxTag.java	14 Mar 2004 06:23:46 -0000	1.25
  +++ MultiboxTag.java	23 Sep 2004 00:34:14 -0000	1.26
  @@ -165,29 +165,47 @@
   
           // 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=\"");
  +
  +        prepareAttribute(results, "name", getProperty());
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +        String value = prepareValue(results);
  +        prepareChecked(results, value);
  +        results.append(prepareEventHandlers());
  +        results.append(prepareStyles());
  +        prepareOtherAttributes(results);
  +        results.append(getElementClose());
  +
  +        TagUtils.getInstance().write(pageContext, results.toString());
  +
  +        return EVAL_PAGE;
  +    }
  +
  +    /**
  +     * Render the value element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected String prepareValue(StringBuffer results) throws JspException {
  +
           String value = (this.value == null) ? this.constant : this.value;
  -            
           if (value == null) {
               JspException e = new JspException(messages.getMessage("multiboxTag.value"));
               pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
               throw e;
           }
  -        results.append(TagUtils.getInstance().filter(value));
  -        results.append("\"");
  +
  +        prepareAttribute(results, "value", TagUtils.getInstance().filter(value));
  +
  +        return value;
  +
  +    }
  +
  +    /**
  +     * Render the checked element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareChecked(StringBuffer results, String value) throws JspException {
  +
           Object bean = TagUtils.getInstance().lookup(pageContext, name, null);
           String values[] = null;
           
  @@ -216,15 +234,9 @@
                   break;
               }
           }
  -        
  -        results.append(prepareEventHandlers());
  -        results.append(prepareStyles());
  -        results.append(getElementClose());
   
  -        TagUtils.getInstance().write(pageContext, results.toString());
  -
  -        return EVAL_PAGE;
       }
  +
   
       /**
        * Release any acquired resources.
  
  
  
  1.29      +27 -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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- RadioTag.java	14 Mar 2004 06:23:46 -0000	1.28
  +++ RadioTag.java	23 Sep 2004 00:34:14 -0000	1.29
  @@ -216,31 +216,17 @@
           throws JspException {
               
           StringBuffer results = new StringBuffer("<input type=\"radio\"");
  -        results.append(" name=\"");
  -        // @since Struts 1.1
  -        if (indexed) {
  -            prepareIndex(results, 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(serverValue);
  -        results.append("\"");
  +
  +        prepareName(results);
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +        prepareAttribute(results, "value", serverValue);
           if (serverValue.equals(checkedValue)) {
               results.append(" checked=\"checked\"");
           }
           results.append(prepareEventHandlers());
           results.append(prepareStyles());
  +        prepareOtherAttributes(results);
           results.append(getElementClose());
           return results.toString();
       }
  @@ -275,6 +261,23 @@
           }
           
           return (EVAL_PAGE);
  +
  +    }
  +
  +    /**
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareName(StringBuffer results) throws JspException {
  +
  +        if (property != null) {
  +            results.append(" name=\"");
  +            // * @since Struts 1.1
  +            if( indexed )
  +                prepareIndex(results, name);
  +            results.append(property);
  +            results.append("\"");
  +        }
   
       }
   
  
  
  
  1.18      +17 -172   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.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ResetTag.java	14 Mar 2004 06:23:46 -0000	1.17
  +++ ResetTag.java	23 Sep 2004 00:34:14 -0000	1.18
  @@ -20,190 +20,35 @@
   
   package org.apache.struts.taglib.html;
   
  -import javax.servlet.jsp.JspException;
  -
  -import org.apache.struts.taglib.TagUtils;
  -import org.apache.struts.util.MessageResources;
  -
   /**
    * Tag for input fields of type "reset".
    *
    * @version $Revision$ $Date$
    */
  -public class ResetTag extends BaseHandlerTag {
  -
  -    // ----------------------------------------------------- Instance Variables
  -
  -    /**
  -     * The message resources for this package.
  -     */
  -    protected static MessageResources messages =
  -        MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
  -
  -    /**
  -     * The name of the generated input field.
  -     */
  -    protected String property = null;
  -
  -    /**
  -     * The body content of this tag (if any).
  -     */
  -    protected String text = null;
  -
  -    /**
  -     * The value of the button label.
  -     */
  -    protected String value = null;
  -
  -    // ------------------------------------------------------------- Properties
  +public class ResetTag extends SubmitTag {
   
       /**
  -     * Return the field name.
  +     * Render the openning element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    public String getProperty() {
  -
  -        return (this.property);
  -
  +    protected String getElementOpen() {
  +        return "<input type=\"reset\"";
       }
   
       /**
  -     * Set the field name.
  -     *
  -     * @param property The field name
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
        */
  -    public void setProperty(String property) {
  -
  -        this.property = property;
  -
  +    protected void prepareName(StringBuffer results) {
  +        prepareAttribute(results, "name", property);
       }
   
       /**
  -     * Return the label value.
  +     * Return the default value
  +     * @param defaultValue The default value if none supplied
        */
  -    public String getValue() {
  -
  -        return (this.value);
  -
  -    }
  -
  -    /**
  -     * Set the label value.
  -     *
  -     * @param value The label value
  -     */
  -    public void setValue(String value) {
  -
  -        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) {
  -                this.text = value;
  -            }
  -        }
  -        return (SKIP_BODY);
  -
  -    }
  -
  -    /**
  -     * Process the end of this tag.
  -     *
  -     * @exception JspException if a JSP exception has occurred
  -     */
  -    public int doEndTag() throws JspException {
  -
  -        TagUtils.getInstance().write(pageContext, renderResetElement(label()));
  -
  -        return (EVAL_PAGE);
  -    }
  -
  -    /**
  -     * Return the label value to display in the reset button.
  -     * @since Struts 1.1
  -     */
  -    protected String label() {
  -        String label = this.value;
  -        
  -        if ((label == null) && (this.text != null)) {
  -            label = this.text;
  -        }
  -        
  -        if ((label == null) || (label.length() < 1)) {
  -            label = "Reset";
  -        }
  -        
  -        return label;
  -    }
  -
  -    /**
  -     * Generate an HTML reset button.
  -     * @param label The text to be displayed on the button.
  -     * @return A fully formed HTML reset button.
  -     * @throws JspException
  -     * @since Struts 1.1
  -     */
  -    protected String renderResetElement(String label) throws JspException {
  -        StringBuffer results = new StringBuffer("<input type=\"reset\"");
  -        
  -        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(this.prepareEventHandlers());
  -        results.append(this.prepareStyles());
  -        results.append(this.getElementClose());
  -        
  -        return results.toString();
  -    }
  -
  -    /**
  -     * Release any acquired resources.
  -     */
  -    public void release() {
  -
  -        super.release();
  -        property = null;
  -        text = null;
  -        value = null;
  -
  +    protected String getDefaultValue() {
  +        return "Reset";
       }
   
   }
  
  
  
  1.23      +26 -26    jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java
  
  Index: SelectTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/SelectTag.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- SelectTag.java	14 Mar 2004 06:23:46 -0000	1.22
  +++ SelectTag.java	23 Sep 2004 00:34:14 -0000	1.23
  @@ -212,33 +212,16 @@
       protected String renderSelectStartElement() throws JspException {
           StringBuffer results = new StringBuffer("<select");
           
  -        results.append(" name=\"");
  -        // * @since Struts 1.1
  -        if (this.indexed) {
  -            prepareIndex(results, name);
  -        }
  -        results.append(property);
  -        results.append("\"");
  -        if (accesskey != null) {
  -            results.append(" accesskey=\"");
  -            results.append(accesskey);
  -            results.append("\"");
  -        }
  +        prepareName(results);
  +        prepareAttribute(results, "accesskey", getAccesskey());
           if (multiple != null) {
               results.append(" multiple=\"multiple\"");
           }
  -        if (size != null) {
  -            results.append(" size=\"");
  -            results.append(size);
  -            results.append("\"");
  -        }
  -        if (tabindex != null) {
  -            results.append(" tabindex=\"");
  -            results.append(tabindex);
  -            results.append("\"");
  -        }
  +        prepareAttribute(results, "size", getSize());
  +        prepareAttribute(results, "tabindex", getTabindex());
           results.append(prepareEventHandlers());
           results.append(prepareStyles());
  +        prepareOtherAttributes(results);
           results.append(">");
           
           return results.toString();
  @@ -331,6 +314,23 @@
           TagUtils.getInstance().write(pageContext, results.toString());
   
           return (EVAL_PAGE);
  +    }
  +
  +    /**
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareName(StringBuffer results) throws JspException {
  +
  +        if (property != null) {
  +            results.append(" name=\"");
  +            // * @since Struts 1.1
  +            if( indexed )
  +                prepareIndex(results, name);
  +            results.append(property);
  +            results.append("\"");
  +        }
  +
       }
   
       /**
  
  
  
  1.22      +65 -34    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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- SubmitTag.java	14 Mar 2004 06:23:46 -0000	1.21
  +++ SubmitTag.java	23 Sep 2004 00:34:14 -0000	1.22
  @@ -153,51 +153,82 @@
        */
       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\"");
  +        results.append(getElementOpen());
  +        prepareName(results);
  +        prepareButtonAttributes(results);
  +        results.append(prepareEventHandlers());
  +        results.append(prepareStyles());
  +        prepareOtherAttributes(results);
  +        results.append(getElementClose());
  +
  +        TagUtils.getInstance().write(pageContext, results.toString());
  +
  +        return (EVAL_PAGE);
  +
  +    }
  +
  +    /**
  +     * Render the openning element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected String getElementOpen() {
  +        return "<input type=\"submit\"";
  +    }
  +
  +    /**
  +     * Render the name element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareName(StringBuffer results) throws JspException {
  +
           if (property != null) {
               results.append(" name=\"");
               results.append(property);
               // * @since Struts 1.1
  -            if (indexed) {
  +            if( indexed )
                   prepareIndex( results, null );
  -            }
               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(getElementClose());
  +    }
   
  -        TagUtils.getInstance().write(pageContext, results.toString());
  +    /**
  +     * Render the button attributes
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareButtonAttributes(StringBuffer results) 
  +                      throws JspException {
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +        prepareValue(results);
  +    }
   
  -        return (EVAL_PAGE);
  +    /**
  +     * Render the value element
  +     * @param results The StringBuffer that output will be appended to.
  +     */
  +    protected void prepareValue(StringBuffer results) {
  +
  +        // 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 = getDefaultValue();
  +
  +        prepareAttribute(results, "value", label);
   
       }
   
  +    /**
  +     * Return the default value
  +     * @param defaultValue The default value if none supplied
  +     */
  +    protected String getDefaultValue() {
  +        return "Submit";
  +    }
   
       /**
        * Release any acquired resources.
  
  
  
  1.20      +10 -48    jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java
  
  Index: TextareaTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/html/TextareaTag.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TextareaTag.java	14 Mar 2004 06:23:46 -0000	1.19
  +++ TextareaTag.java	23 Sep 2004 00:34:14 -0000	1.20
  @@ -32,23 +32,6 @@
   public class TextareaTag extends BaseInputTag {
   
   
  -    // ----------------------------------------------------- Instance Variables
  -
  -
  -    /**
  -     * The name of the bean containing our underlying property.
  -     */
  -    protected String name = Constants.BEAN_KEY;
  -
  -    public String getName() {
  -        return (this.name);
  -    }
  -
  -    public void setName(String name) {
  -        this.name = name;
  -    }
  -
  -
       // --------------------------------------------------------- Public Methods
   
   
  @@ -73,35 +56,14 @@
       protected String renderTextareaElement() throws JspException {
           StringBuffer results = new StringBuffer("<textarea");
           
  -        results.append(" name=\"");
  -        // @since Struts 1.1
  -        if (indexed) {
  -            prepareIndex(results, 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("\"");
  -        }
  +        prepareName(results);
  +        prepareAttribute(results, "accesskey", getAccesskey());
  +        prepareAttribute(results, "tabindex", getTabindex());
  +        prepareAttribute(results, "cols", getCols());
  +        prepareAttribute(results, "rows", getRows());
           results.append(prepareEventHandlers());
           results.append(prepareStyles());
  +        prepareOtherAttributes(results);
           results.append(">");
           
           results.append(this.renderData());
  
  
  
  1.5       +16 -16    jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestCancelTag1.jsp
  
  Index: TestCancelTag1.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestCancelTag1.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestCancelTag1.jsp	26 Dec 2003 22:08:01 -0000	1.4
  +++ TestCancelTag1.jsp	23 Sep 2004 00:34:15 -0000	1.5
  @@ -27,7 +27,7 @@
   		<html:cancel alt="Testing alt attribute"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" alt="Testing alt attribute" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" alt="Testing alt attribute">
   	</bean:define>
   </logic:equal>
   
  @@ -36,7 +36,7 @@
   		<html:cancel altKey="default.bundle.message"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" alt="Testing Message" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" alt="Testing Message">
   	</bean:define>
   </logic:equal>
   
  @@ -54,7 +54,7 @@
   		<html:cancel altKey="default.bundle.message"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" alt="Message D'Essai" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" alt="Message D'Essai">
   	</bean:define>
   </logic:equal>
   
  @@ -72,7 +72,7 @@
   		<html:cancel disabled="true"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" disabled="disabled" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" disabled="disabled">
   	</bean:define>
   </logic:equal>
   
  @@ -104,7 +104,7 @@
   		<html:cancel onblur="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onblur="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onblur="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -115,7 +115,7 @@
   		<html:cancel onchange="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onchange="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onchange="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -135,7 +135,7 @@
   		<html:cancel ondblclick="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" ondblclick="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" ondblclick="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -145,7 +145,7 @@
   		<html:cancel onfocus="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onfocus="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onfocus="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -155,7 +155,7 @@
   		<html:cancel onkeydown="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onkeydown="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onkeydown="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -165,7 +165,7 @@
   		<html:cancel onkeypress="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onkeypress="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onkeypress="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -175,7 +175,7 @@
   		<html:cancel onkeyup="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onkeyup="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onkeyup="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -185,7 +185,7 @@
   		<html:cancel onmousedown="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onmousedown="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onmousedown="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -195,7 +195,7 @@
   		<html:cancel onmousemove="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onmousemove="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onmousemove="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -205,7 +205,7 @@
   		<html:cancel onmouseout="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onmouseout="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onmouseout="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -215,7 +215,7 @@
   		<html:cancel onmouseover="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onmouseover="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onmouseover="Put script here">
   	</bean:define>
   </logic:equal>
   
  @@ -225,7 +225,7 @@
   		<html:cancel onmouseup="Put script here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onmouseup="Put script here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" onmouseup="Put script here">
   	</bean:define>
   </logic:equal>
   
  
  
  
  1.5       +6 -6      jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestCancelTag2.jsp
  
  Index: TestCancelTag2.jsp
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/web/test/test/org/apache/struts/taglib/html/TestCancelTag2.jsp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestCancelTag2.jsp	26 Dec 2003 22:08:01 -0000	1.4
  +++ TestCancelTag2.jsp	23 Sep 2004 00:34:15 -0000	1.5
  @@ -10,7 +10,7 @@
   		<html:cancel style="Put something here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" style="Put something here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" style="Put something here">
   	</bean:define>
   </logic:equal>
   
  @@ -19,7 +19,7 @@
   		<html:cancel styleClass="Put something here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" class="Put something here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" class="Put something here">
   	</bean:define>
   </logic:equal>
   
  @@ -28,7 +28,7 @@
   		<html:cancel styleId="Put something here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" id="Put something here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" id="Put something here">
   	</bean:define>
   </logic:equal>
   
  @@ -46,7 +46,7 @@
   		<html:cancel title="Put something here"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" title="Put something here" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" title="Put something here">
   	</bean:define>
   </logic:equal>
   
  @@ -55,7 +55,7 @@
   		<html:cancel titleKey="default.bundle.message"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" title="Testing Message" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" title="Testing Message">
   	</bean:define>
   </logic:equal>
   
  @@ -64,7 +64,7 @@
   		<html:cancel titleKey="default.bundle.message"/>
   	</bean:define>
   	<bean:define id="EXPECTED_RESULTS" toScope="page">
  -		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" title="Message D'Essai" onclick="bCancel=true;">
  +		<input type="submit" name="org.apache.struts.taglib.html.CANCEL" value="Cancel" onclick="bCancel=true;" title="Message D'Essai">
   	</bean:define>
   </logic:equal>
   
  
  
  

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