Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SelectTag.java URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SelectTag.java?rev=376841&r1=376840&r2=376841&view=diff ============================================================================== --- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SelectTag.java (original) +++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SelectTag.java Fri Feb 10 13:01:28 2006 @@ -1,62 +1,84 @@ /* - * $Id$ + * $Id$ * * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.taglib.html; -import java.lang.reflect.InvocationTargetException; - -import javax.servlet.jsp.JspException; - import org.apache.commons.beanutils.BeanUtils; import org.apache.struts.taglib.TagUtils; import org.apache.struts.util.MessageResources; +import javax.servlet.jsp.JspException; + +import java.lang.reflect.InvocationTargetException; + /** - * Custom tag that represents an HTML select element, associated with a - * bean property specified by our attributes. This tag must be nested - * inside a form tag. + * Custom tag that represents an HTML select element, associated with a bean + * property specified by our attributes. This tag must be nested inside a + * form tag. * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004) + * $ */ public class SelectTag extends BaseHandlerTag { - + /** + * The message resources for this package. + */ + protected static MessageResources messages = + MessageResources.getMessageResources(Constants.Package + + ".LocalStrings"); // ----------------------------------------------------- Instance Variables - /** * The actual values we will match against, calculated in doStartTag(). */ - protected String match[] = null; + protected String[] match = null; + /** + * Should multiple selections be allowed. Any non-null value will trigger + * rendering this. + */ + protected String multiple = null; /** - * The message resources for this package. + * The name of the bean containing our underlying property. */ - protected static MessageResources messages = - MessageResources.getMessageResources(Constants.Package + ".LocalStrings"); + protected String name = Constants.BEAN_KEY; + + /** + * The property name we are associated with. + */ + protected String property = null; + /** + * The saved body content of this tag. + */ + protected String saveBody = null; /** - * Should multiple selections be allowed. Any non-null value will - * trigger rendering this. + * How many available options should be displayed when this element is + * rendered? */ - protected String multiple = null; + protected String size = null; + + /** + * The value to compare with for marking an option selected. + */ + protected String value = null; public String getMultiple() { return (this.multiple); @@ -66,12 +88,6 @@ this.multiple = multiple; } - - /** - * The name of the bean containing our underlying property. - */ - protected String name = Constants.BEAN_KEY; - public String getName() { return (this.name); } @@ -80,25 +96,6 @@ this.name = name; } - - /** - * The property name we are associated with. - */ - protected String property = null; - - - /** - * The saved body content of this tag. - */ - protected String saveBody = null; - - - /** - * How many available options should be displayed when this element - * is rendered? - */ - protected String size = null; - public String getSize() { return (this.size); } @@ -107,16 +104,8 @@ this.size = size; } - - /** - * The value to compare with for marking an option selected. - */ - protected String value = null; - - // ------------------------------------------------------------- Properties - /** * Does the specified value match one of those we are looking for? * @@ -126,72 +115,57 @@ if ((this.match == null) || (value == null)) { return false; } - + for (int i = 0; i < this.match.length; i++) { - if (value.equals(this.match[i])) + if (value.equals(this.match[i])) { return true; + } } - + return false; } - /** * Return the property name. */ public String getProperty() { - return (this.property); - } - /** * Set the property name. * * @param property The new property name */ public void setProperty(String property) { - this.property = property; - } - /** * Return the comparison value. */ public String getValue() { - return (this.value); - } - /** * Set the comparison value. * * @param value The new comparison value */ public void setValue(String value) { - this.value = value; - } - // --------------------------------------------------------- Public Methods - /** - * Render the beginning of this select tag. - * <p> - * Support for indexed property since Struts 1.1 + * Render the beginning of this select tag. <p> Support for indexed + * property since Struts 1.1 * - * @exception JspException if a JSP exception has occurred + * @throws JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { - TagUtils.getInstance().write(pageContext, renderSelectStartElement()); // Store this tag itself as a page attribute @@ -204,109 +178,114 @@ /** * Create an appropriate select start element based on our parameters. + * * @throws JspException * @since Struts 1.1 */ - protected String renderSelectStartElement() throws JspException { + protected String renderSelectStartElement() + throws JspException { StringBuffer results = new StringBuffer("<select"); - + prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); + if (multiple != null) { results.append(" multiple=\"multiple\""); } + prepareAttribute(results, "size", getSize()); prepareAttribute(results, "tabindex", getTabindex()); results.append(prepareEventHandlers()); results.append(prepareStyles()); prepareOtherAttributes(results); results.append(">"); - + return results.toString(); } /** * Calculate the match values we will actually be using. + * * @throws JspException */ - private void calculateMatchValues() throws JspException { + private void calculateMatchValues() + throws JspException { if (this.value != null) { this.match = new String[1]; this.match[0] = this.value; - } else { - Object bean = TagUtils.getInstance().lookup(pageContext, name, null); + Object bean = + TagUtils.getInstance().lookup(pageContext, name, null); + if (bean == null) { JspException e = new JspException(messages.getMessage("getter.bean", name)); - + TagUtils.getInstance().saveException(pageContext, e); throw e; } try { this.match = BeanUtils.getArrayProperty(bean, property); + if (this.match == null) { this.match = new String[0]; } - } catch (IllegalAccessException e) { TagUtils.getInstance().saveException(pageContext, e); - throw new JspException( - messages.getMessage("getter.access", property, name)); - + throw new JspException(messages.getMessage("getter.access", + property, name)); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); - TagUtils.getInstance().saveException(pageContext, t); - throw new JspException( - messages.getMessage("getter.result", property, t.toString())); + TagUtils.getInstance().saveException(pageContext, t); + throw new JspException(messages.getMessage("getter.result", + property, t.toString())); } catch (NoSuchMethodException e) { TagUtils.getInstance().saveException(pageContext, e); - throw new JspException( - messages.getMessage("getter.method", property, name)); + throw new JspException(messages.getMessage("getter.method", + property, name)); } } } - /** * Save any body content of this tag, which will generally be the * option(s) representing the values displayed to the user. * - * @exception JspException if a JSP exception has occurred + * @throws JspException if a JSP exception has occurred */ public int doAfterBody() throws JspException { - if (bodyContent != null) { String value = bodyContent.getString(); + if (value == null) { value = ""; } - + this.saveBody = value.trim(); } - + return (SKIP_BODY); } - /** * Render the end of this form. * - * @exception JspException if a JSP exception has occurred + * @throws JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { - // Remove the page scope attributes we created pageContext.removeAttribute(Constants.SELECT_KEY); // Render a tag representing the end of our current form StringBuffer results = new StringBuffer(); + if (saveBody != null) { results.append(saveBody); saveBody = null; } + results.append("</select>"); TagUtils.getInstance().write(pageContext, results.toString()); @@ -316,31 +295,32 @@ /** * Prepare the name element + * * @return The element name. */ - protected String prepareName() throws JspException { - + protected String prepareName() + throws JspException { if (property == null) { return null; } // * @since Struts 1.1 - if(indexed) { + if (indexed) { StringBuffer results = new StringBuffer(); + prepareIndex(results, name); results.append(property); + return results.toString(); } return property; - } /** * Release any acquired resources. */ public void release() { - super.release(); match = null; multiple = null; @@ -349,7 +329,5 @@ saveBody = null; size = null; value = null; - } - }
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SubmitTag.java URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SubmitTag.java?rev=376841&r1=376840&r2=376841&view=diff ============================================================================== --- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SubmitTag.java (original) +++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SubmitTag.java Fri Feb 10 13:01:28 2006 @@ -1,158 +1,133 @@ /* - * $Id$ + * $Id$ * * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.taglib.html; -import javax.servlet.jsp.JspException; - import org.apache.struts.taglib.TagUtils; import org.apache.struts.util.MessageResources; +import javax.servlet.jsp.JspException; + /** * Tag for input fields of type "submit". * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2005-04-06 02:22:39 -0400 (Wed, 06 Apr 2005) + * $ */ public class SubmitTag extends BaseHandlerTag { - - // ----------------------------------------------------- Instance Variables - /** * The message resources for this package. */ protected static MessageResources messages = - MessageResources.getMessageResources(Constants.Package + ".LocalStrings"); - + 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 - /** * Return the property. */ public String getProperty() { - return (this.property); - } - /** * Set the property name. * * @param property The property name */ public void setProperty(String property) { - this.property = property; - } - /** * Return the label value. */ 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 + * @throws 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); + return (EVAL_BODY_TAG); } - - /** * Save the associated label from the body content. * - * @exception JspException if a JSP exception has occurred + * @throws 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); + return (SKIP_BODY); } - /** - * Process the end of this tag. - * <p> - * Support for Indexed property since Struts 1.1 + * Process the end of this tag. <p> Support for Indexed property since + * Struts 1.1 * - * @exception JspException if a JSP exception has occurred + * @throws JspException if a JSP exception has occurred */ public int doEndTag() throws JspException { - // Generate an HTML element StringBuffer results = new StringBuffer(); + results.append(getElementOpen()); prepareAttribute(results, "name", prepareName()); prepareButtonAttributes(results); @@ -164,7 +139,6 @@ TagUtils.getInstance().write(pageContext, results.toString()); return (EVAL_PAGE); - } /** @@ -176,35 +150,37 @@ return "<input type=\"submit\""; } - /** * Prepare the name element + * * @return The element name. */ - protected String prepareName() throws JspException { - + protected String prepareName() + throws JspException { if (property == null) { return null; } // * @since Struts 1.1 - if(indexed) { + if (indexed) { StringBuffer results = new StringBuffer(); + results.append(property); prepareIndex(results, null); + return results.toString(); } return property; - } /** * Render the button attributes + * * @param results The StringBuffer that output will be appended to. */ - protected void prepareButtonAttributes(StringBuffer results) - throws JspException { + protected void prepareButtonAttributes(StringBuffer results) + throws JspException { prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); prepareValue(results); @@ -212,19 +188,22 @@ /** * 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)) + + if ((label == null) && (text != null)) { label = text; - if ((label == null) || (label.length() < 1)) + } + + if ((label == null) || (label.length() < 1)) { label = getDefaultValue(); + } prepareAttribute(results, "value", label); - } /** @@ -240,13 +219,9 @@ * Release any acquired resources. */ public void release() { - super.release(); property = null; text = null; value = null; - } - - } Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextTag.java URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextTag.java?rev=376841&r1=376840&r2=376841&view=diff ============================================================================== --- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextTag.java (original) +++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextTag.java Fri Feb 10 13:01:28 2006 @@ -1,44 +1,36 @@ /* - * $Id$ + * $Id$ * * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */ - - + */ package org.apache.struts.taglib.html; /** * Custom tag for input fields of type "text". * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2005-04-06 02:37:00 -0400 (Wed, 06 Apr 2005) + * $ */ - public class TextTag extends BaseFieldTag { - - /** * Construct a new instance of this tag. */ public TextTag() { - - super(); - this.type = "text"; - doReadonly = true; - + super(); + this.type = "text"; + doReadonly = true; } - - } Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextareaTag.java URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextareaTag.java?rev=376841&r1=376840&r2=376841&view=diff ============================================================================== --- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextareaTag.java (original) +++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextareaTag.java Fri Feb 10 13:01:28 2006 @@ -1,53 +1,47 @@ /* - * $Id$ + * $Id$ * * Copyright 1999-2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.taglib.html; -import javax.servlet.jsp.JspException; - import org.apache.struts.taglib.TagUtils; +import javax.servlet.jsp.JspException; + /** * Custom tag for input fields of type "textarea". * - * @version $Rev$ $Date$ + * @version $Rev$ $Date: 2005-04-06 02:37:00 -0400 (Wed, 06 Apr 2005) + * $ */ public class TextareaTag extends BaseInputTag { - - // ----------------------------------------------------- Constructor - - public TextareaTag () { + public TextareaTag() { super(); doReadonly = true; } // --------------------------------------------------------- Public Methods - /** - * Generate the required input tag. - * Support for indexed since Struts 1.1 + * Generate the required input tag. Support for indexed since Struts 1.1 * - * @exception JspException if a JSP exception has occurred + * @throws JspException if a JSP exception has occurred */ public int doStartTag() throws JspException { - TagUtils.getInstance().write(pageContext, this.renderTextareaElement()); return (EVAL_BODY_TAG); @@ -55,12 +49,14 @@ /** * Generate an HTML <textarea> tag. + * * @throws JspException * @since Struts 1.1 */ - protected String renderTextareaElement() throws JspException { + protected String renderTextareaElement() + throws JspException { StringBuffer results = new StringBuffer("<textarea"); - + prepareAttribute(results, "name", prepareName()); prepareAttribute(results, "accesskey", getAccesskey()); prepareAttribute(results, "tabindex", getTabindex()); @@ -70,25 +66,28 @@ results.append(prepareStyles()); prepareOtherAttributes(results); results.append(">"); - + results.append(this.renderData()); - + results.append("</textarea>"); + return results.toString(); } /** * Renders the value displayed in the <textarea> tag. + * * @throws JspException * @since Struts 1.1 */ - protected String renderData() throws JspException { + protected String renderData() + throws JspException { String data = this.value; if (data == null) { data = this.lookupProperty(this.name, this.property); } - + return (data == null) ? "" : TagUtils.getInstance().filter(data); } @@ -96,10 +95,7 @@ * Release any acquired resources. */ public void release() { - super.release(); name = Constants.BEAN_KEY; - } - } Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/XhtmlTag.java URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/XhtmlTag.java?rev=376841&r1=376840&r2=376841&view=diff ============================================================================== --- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/XhtmlTag.java (original) +++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/XhtmlTag.java Fri Feb 10 13:01:28 2006 @@ -1,40 +1,34 @@ /* - * $Id$ + * $Id$ * * Copyright 2003,2004 The Apache Software Foundation. - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.struts.taglib.html; +import org.apache.struts.Globals; + import javax.servlet.jsp.JspException; import javax.servlet.jsp.PageContext; import javax.servlet.jsp.tagext.TagSupport; -import org.apache.struts.Globals; - /** - * This tag tells all other html taglib tags to render themselves in xhtml. It has no - * attributes; it's presence in a page turns on xhtml. - * <p> - * Example:<br/> - * <html:xhtml/> - * </p> - * + * This tag tells all other html taglib tags to render themselves in xhtml. It + * has no attributes; it's presence in a page turns on xhtml. <p> + * Example:<br/> <html:xhtml/> </p> */ public class XhtmlTag extends TagSupport { - /** * Constructor for XhtmlTag. */ @@ -46,8 +40,9 @@ * @see javax.servlet.jsp.tagext.Tag#doEndTag() */ public int doEndTag() throws JspException { - this.pageContext.setAttribute(Globals.XHTML_KEY, "true", PageContext.PAGE_SCOPE); + this.pageContext.setAttribute(Globals.XHTML_KEY, "true", + PageContext.PAGE_SCOPE); + return EVAL_PAGE; } - } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
