You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by hu...@apache.org on 2006/02/10 22:01:32 UTC
svn commit: r376841 [1/6] -
/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/
Author: husted
Date: Fri Feb 10 13:01:28 2006
New Revision: 376841
URL: http://svn.apache.org/viewcvs?rev=376841&view=rev
Log:
Checkstyle Roundup
* Taglib html package reformatted with latest Jalopy settings. Stylistic changes only.
Modified:
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseFieldTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseHandlerTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseInputTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ButtonTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CancelTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CheckboxTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/Constants.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ErrorsTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/FileTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/FormTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/FrameTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/HiddenTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/HtmlTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ImageTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ImgTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/JavascriptValidatorTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/LinkTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/MessagesTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/MessagesTei.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/MultiboxTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/OptionTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/OptionsCollectionTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/OptionsTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/PasswordTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/RadioTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ResetTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/RewriteTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SelectTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/SubmitTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/TextareaTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/XhtmlTag.java
struts/taglib/trunk/src/java/org/apache/struts/taglib/html/package.html
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseFieldTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseFieldTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseFieldTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseFieldTag.java Fri Feb 10 13:01:28 2006
@@ -1,45 +1,54 @@
/*
- * $Id$
+ * $Id$
*
* Copyright 2001-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;
+
/**
* Convenience base class for the various input tags for text fields.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
-
public abstract class BaseFieldTag extends BaseInputTag {
-
// ----------------------------------------------------- Instance Variables
/**
- * Comma-delimited list of content types that a server processing this form
- * will handle correctly. This property is defined only for the
+ * Comma-delimited list of content types that a server processing this
+ * form will handle correctly. This property is defined only for the
* <code>file</code> tag, but is implemented here because it affects the
* rendered HTML of the corresponding <input> tag.
*/
protected String accept = null;
+ /**
+ * The "redisplay contents" flag (used only on <code>password</code>).
+ */
+ protected boolean redisplay = true;
+
+ /**
+ * The type of input field represented by this tag (text, password, or
+ * hidden).
+ */
+ protected String type = null;
+
public String getAccept() {
return (this.accept);
}
@@ -48,11 +57,6 @@
this.accept = accept;
}
- /**
- * The "redisplay contents" flag (used only on <code>password</code>).
- */
- protected boolean redisplay = true;
-
public boolean getRedisplay() {
return (this.redisplay);
}
@@ -61,35 +65,28 @@
this.redisplay = redisplay;
}
- /**
- * The type of input field represented by this tag (text, password, or
- * hidden).
- */
- protected String type = null;
-
// --------------------------------------------------------- Public Methods
/**
- * Generate the required input tag.
- * <p>
- * Support for indexed property since Struts 1.1
+ * Generate the required input 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(this.pageContext, this.renderInputElement());
return (EVAL_BODY_TAG);
-
}
/**
* Renders a fully formed <input> element.
+ *
* @throws JspException
* @since Struts 1.2
*/
- protected String renderInputElement() throws JspException {
+ protected String renderInputElement()
+ throws JspException {
StringBuffer results = new StringBuffer("<input");
prepareAttribute(results, "type", this.type);
@@ -104,19 +101,21 @@
results.append(this.prepareStyles());
prepareOtherAttributes(results);
results.append(this.getElementClose());
+
return results.toString();
}
/**
* Render the value element
+ *
* @param results The StringBuffer that output will be appended to.
*/
- protected void prepareValue(StringBuffer results) throws JspException {
-
+ protected void prepareValue(StringBuffer results)
+ throws JspException {
results.append(" value=\"");
+
if (value != null) {
results.append(this.formatValue(value));
-
} else if (redisplay || !"password".equals(type)) {
Object value =
TagUtils.getInstance().lookup(pageContext, name, property, null);
@@ -125,21 +124,19 @@
}
results.append('"');
-
}
-
+
/**
- * Return the given value as a formatted <code>String</code>. This
+ * Return the given value as a formatted <code>String</code>. This
* implementation escapes potentially harmful HTML characters.
*
* @param value The value to be formatted. <code>null</code> values will
- * be returned as the empty String "".
- *
+ * be returned as the empty String "".
* @throws JspException if a JSP exception has occurred
- *
* @since Struts 1.2
*/
- protected String formatValue(Object value) throws JspException {
+ protected String formatValue(Object value)
+ throws JspException {
if (value == null) {
return "";
}
@@ -151,12 +148,9 @@
* Release any acquired resources.
*/
public void release() {
-
super.release();
accept = null;
name = Constants.BEAN_KEY;
redisplay = true;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseHandlerTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseHandlerTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseHandlerTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseHandlerTag.java Fri Feb 10 13:01:28 2006
@@ -1,31 +1,22 @@
/*
- * $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 java.lang.reflect.Method;
-import java.util.Locale;
-
-import javax.servlet.jsp.PageContext;
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.tagext.BodyTagSupport;
-
import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -36,16 +27,23 @@
import org.apache.struts.util.MessageResources;
import org.apache.struts.util.RequestUtils;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.PageContext;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
/**
- * Base class for tags that render form elements capable of including JavaScript
- * event handlers and/or CSS Style attributes. This class does not implement
- * the doStartTag() or doEndTag() methods. Subclasses should provide
+ * Base class for tags that render form elements capable of including
+ * JavaScript event handlers and/or CSS Style attributes. This class does not
+ * implement the doStartTag() or doEndTag() methods. Subclasses should provide
* appropriate implementations of these.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-08-21 19:08:45 -0400 (Sun, 21 Aug 2005)
+ * $
*/
public abstract class BaseHandlerTag extends BodyTagSupport {
-
/**
* Commons Logging instance.
*/
@@ -57,169 +55,253 @@
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
+ MessageResources.getMessageResources(Constants.Package
+ + ".LocalStrings");
// Navigation Management
- /** Access key character. */
+ /**
+ * Access key character.
+ */
protected String accesskey = null;
- /** Tab index value. */
+ /**
+ * Tab index value.
+ */
protected String tabindex = null;
// Indexing ability for Iterate
- /** Whether to created indexed names for fields
+ /**
+ * Whether to created indexed names for fields
+ *
* @since Struts 1.1
*/
protected boolean indexed = false;
// Mouse Events
- /** Mouse click event. */
+ /**
+ * Mouse click event.
+ */
private String onclick = null;
- /** Mouse double click event. */
+ /**
+ * Mouse double click event.
+ */
private String ondblclick = null;
- /** Mouse over component event. */
+ /**
+ * Mouse over component event.
+ */
private String onmouseover = null;
- /** Mouse exit component event. */
+ /**
+ * Mouse exit component event.
+ */
private String onmouseout = null;
- /** Mouse moved over component event. */
+ /**
+ * Mouse moved over component event.
+ */
private String onmousemove = null;
- /** Mouse pressed on component event. */
+ /**
+ * Mouse pressed on component event.
+ */
private String onmousedown = null;
- /** Mouse released on component event. */
+ /**
+ * Mouse released on component event.
+ */
private String onmouseup = null;
// Keyboard Events
- /** Key down in component event. */
+ /**
+ * Key down in component event.
+ */
private String onkeydown = null;
- /** Key released in component event. */
+ /**
+ * Key released in component event.
+ */
private String onkeyup = null;
- /** Key down and up together in component event. */
+ /**
+ * Key down and up together in component event.
+ */
private String onkeypress = null;
// Text Events
- /** Text selected in component event. */
+ /**
+ * Text selected in component event.
+ */
private String onselect = null;
- /** Content changed after component lost focus event. */
+ /**
+ * Content changed after component lost focus event.
+ */
private String onchange = null;
// Focus Events and States
- /** Component lost focus event. */
+ /**
+ * Component lost focus event.
+ */
private String onblur = null;
- /** Component has received focus event. */
+ /**
+ * Component has received focus event.
+ */
private String onfocus = null;
- /** Component is disabled. */
+ /**
+ * Component is disabled.
+ */
private boolean disabled = false;
- /** Indicates whether 'disabled' is a valid attribute */
+ /**
+ * Indicates whether 'disabled' is a valid attribute
+ */
protected boolean doDisabled = true;
- /** Component is readonly. */
+ /**
+ * Component is readonly.
+ */
private boolean readonly = false;
- /**
+ /**
* <p>Indicates whether 'readonly' is a valid attribute.</p>
*
- * <p>According to the HTML 4.0 Specification <readonly>
- * is valid for <input type="text">, <input type="password">
- * and <textarea"> elements. Therefore, except for those tags this
- * value is set to <code>false</code>.</p>
+ * <p>According to the HTML 4.0 Specification <readonly> is valid
+ * for <input type="text">, <input type="password"> and
+ * <textarea"> elements. Therefore, except for those tags this value
+ * is set to <code>false</code>.</p>
*/
protected boolean doReadonly = false;
// CSS Style Support
- /** Style attribute associated with component. */
+ /**
+ * Style attribute associated with component.
+ */
private String style = null;
- /** Named Style class associated with component. */
+ /**
+ * Named Style class associated with component.
+ */
private String styleClass = null;
- /** Identifier associated with component. */
+ /**
+ * Identifier associated with component.
+ */
private String styleId = null;
- /** The request attribute key for our error messages (if any). */
+ /**
+ * The request attribute key for our error messages (if any).
+ */
private String errorKey = Globals.ERROR_KEY;
- /** Style attribute associated with component when errors exist. */
+ /**
+ * Style attribute associated with component when errors exist.
+ */
private String errorStyle = null;
- /** Named Style class associated with component when errors exist. */
+ /**
+ * Named Style class associated with component when errors exist.
+ */
private String errorStyleClass = null;
- /** Identifier associated with component when errors exist. */
+ /**
+ * Identifier associated with component when errors exist.
+ */
private String errorStyleId = null;
// Other Common Attributes
- /** The alternate text of this element. */
+ /**
+ * The alternate text of this element.
+ */
private String alt = null;
- /** The message resources key of the alternate text. */
+ /**
+ * The message resources key of the alternate text.
+ */
private String altKey = null;
- /** The name of the message resources bundle for message lookups. */
+ /**
+ * The name of the message resources bundle for message lookups.
+ */
private String bundle = null;
- /** The name of the session attribute key for our locale. */
+ /**
+ * The name of the session attribute key for our locale.
+ */
private String locale = Globals.LOCALE_KEY;
- /** The advisory title of this element. */
+ /**
+ * The advisory title of this element.
+ */
private String title = null;
- /** The message resources key of the advisory title. */
+ /**
+ * The message resources key of the advisory title.
+ */
private String titleKey = null;
+ private Class loopTagSupportClass = null;
+ private Method loopTagSupportGetStatus = null;
+ private Class loopTagStatusClass = null;
+ private Method loopTagStatusGetIndex = null;
+ private boolean triedJstlInit = false;
+ private boolean triedJstlSuccess = false;
// ------------------------------------------------------------- Properties
-
// Navigation Management
- /** Sets the accessKey character. */
+ /**
+ * Sets the accessKey character.
+ */
public void setAccesskey(String accessKey) {
this.accesskey = accessKey;
}
- /** Returns the accessKey character. */
+ /**
+ * Returns the accessKey character.
+ */
public String getAccesskey() {
return (this.accesskey);
}
- /** Sets the tabIndex value. */
+ /**
+ * Sets the tabIndex value.
+ */
public void setTabindex(String tabIndex) {
this.tabindex = tabIndex;
}
- /** Returns the tabIndex value. */
+ /**
+ * Returns the tabIndex value.
+ */
public String getTabindex() {
return (this.tabindex);
}
// Indexing ability for Iterate [since Struts 1.1]
- /** Sets the indexed value.
+ /**
+ * Sets the indexed value.
+ *
* @since Struts 1.1
*/
public void setIndexed(boolean indexed) {
this.indexed = indexed;
}
- /** Returns the indexed value.
+ /**
+ * Returns the indexed value.
+ *
* @since Struts 1.1
*/
public boolean getIndexed() {
@@ -228,302 +310,418 @@
// Mouse Events
- /** Sets the onClick event handler. */
+ /**
+ * Sets the onClick event handler.
+ */
public void setOnclick(String onClick) {
this.onclick = onClick;
}
- /** Returns the onClick event handler. */
+ /**
+ * Returns the onClick event handler.
+ */
public String getOnclick() {
return onclick;
}
- /** Sets the onDblClick event handler. */
+ /**
+ * Sets the onDblClick event handler.
+ */
public void setOndblclick(String onDblClick) {
this.ondblclick = onDblClick;
}
- /** Returns the onDblClick event handler. */
+ /**
+ * Returns the onDblClick event handler.
+ */
public String getOndblclick() {
return ondblclick;
}
- /** Sets the onMouseDown event handler. */
+ /**
+ * Sets the onMouseDown event handler.
+ */
public void setOnmousedown(String onMouseDown) {
this.onmousedown = onMouseDown;
}
- /** Returns the onMouseDown event handler. */
+ /**
+ * Returns the onMouseDown event handler.
+ */
public String getOnmousedown() {
return onmousedown;
}
- /** Sets the onMouseUp event handler. */
+ /**
+ * Sets the onMouseUp event handler.
+ */
public void setOnmouseup(String onMouseUp) {
this.onmouseup = onMouseUp;
}
- /** Returns the onMouseUp event handler. */
+ /**
+ * Returns the onMouseUp event handler.
+ */
public String getOnmouseup() {
return onmouseup;
}
- /** Sets the onMouseMove event handler. */
+ /**
+ * Sets the onMouseMove event handler.
+ */
public void setOnmousemove(String onMouseMove) {
this.onmousemove = onMouseMove;
}
- /** Returns the onMouseMove event handler. */
+ /**
+ * Returns the onMouseMove event handler.
+ */
public String getOnmousemove() {
return onmousemove;
}
- /** Sets the onMouseOver event handler. */
+ /**
+ * Sets the onMouseOver event handler.
+ */
public void setOnmouseover(String onMouseOver) {
this.onmouseover = onMouseOver;
}
- /** Returns the onMouseOver event handler. */
+ /**
+ * Returns the onMouseOver event handler.
+ */
public String getOnmouseover() {
return onmouseover;
}
- /** Sets the onMouseOut event handler. */
+ /**
+ * Sets the onMouseOut event handler.
+ */
public void setOnmouseout(String onMouseOut) {
this.onmouseout = onMouseOut;
}
- /** Returns the onMouseOut event handler. */
+ /**
+ * Returns the onMouseOut event handler.
+ */
public String getOnmouseout() {
return onmouseout;
}
// Keyboard Events
- /** Sets the onKeyDown event handler. */
+ /**
+ * Sets the onKeyDown event handler.
+ */
public void setOnkeydown(String onKeyDown) {
this.onkeydown = onKeyDown;
}
- /** Returns the onKeyDown event handler. */
+ /**
+ * Returns the onKeyDown event handler.
+ */
public String getOnkeydown() {
return onkeydown;
}
- /** Sets the onKeyUp event handler. */
+ /**
+ * Sets the onKeyUp event handler.
+ */
public void setOnkeyup(String onKeyUp) {
this.onkeyup = onKeyUp;
}
- /** Returns the onKeyUp event handler. */
+ /**
+ * Returns the onKeyUp event handler.
+ */
public String getOnkeyup() {
return onkeyup;
}
- /** Sets the onKeyPress event handler. */
+ /**
+ * Sets the onKeyPress event handler.
+ */
public void setOnkeypress(String onKeyPress) {
this.onkeypress = onKeyPress;
}
- /** Returns the onKeyPress event handler. */
+ /**
+ * Returns the onKeyPress event handler.
+ */
public String getOnkeypress() {
return onkeypress;
}
// Text Events
- /** Sets the onChange event handler. */
+ /**
+ * Sets the onChange event handler.
+ */
public void setOnchange(String onChange) {
this.onchange = onChange;
}
- /** Returns the onChange event handler. */
+ /**
+ * Returns the onChange event handler.
+ */
public String getOnchange() {
return onchange;
}
- /** Sets the onSelect event handler. */
+ /**
+ * Sets the onSelect event handler.
+ */
public void setOnselect(String onSelect) {
this.onselect = onSelect;
}
- /** Returns the onSelect event handler. */
+ /**
+ * Returns the onSelect event handler.
+ */
public String getOnselect() {
return onselect;
}
// Focus Events and States
- /** Sets the onBlur event handler. */
+ /**
+ * Sets the onBlur event handler.
+ */
public void setOnblur(String onBlur) {
this.onblur = onBlur;
}
- /** Returns the onBlur event handler. */
+ /**
+ * Returns the onBlur event handler.
+ */
public String getOnblur() {
return onblur;
}
- /** Sets the onFocus event handler. */
+ /**
+ * Sets the onFocus event handler.
+ */
public void setOnfocus(String onFocus) {
this.onfocus = onFocus;
}
- /** Returns the onFocus event handler. */
+ /**
+ * Returns the onFocus event handler.
+ */
public String getOnfocus() {
return onfocus;
}
- /** Sets the disabled event handler. */
+ /**
+ * Sets the disabled event handler.
+ */
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
- /** Returns the disabled event handler. */
+ /**
+ * Returns the disabled event handler.
+ */
public boolean getDisabled() {
return disabled;
}
- /** Sets the readonly event handler. */
+ /**
+ * Sets the readonly event handler.
+ */
public void setReadonly(boolean readonly) {
this.readonly = readonly;
}
- /** Returns the readonly event handler. */
+ /**
+ * Returns the readonly event handler.
+ */
public boolean getReadonly() {
return readonly;
}
// CSS Style Support
- /** Sets the style attribute. */
+ /**
+ * Sets the style attribute.
+ */
public void setStyle(String style) {
this.style = style;
}
- /** Returns the style attribute. */
+ /**
+ * Returns the style attribute.
+ */
public String getStyle() {
return style;
}
- /** Sets the style class attribute. */
+ /**
+ * Sets the style class attribute.
+ */
public void setStyleClass(String styleClass) {
this.styleClass = styleClass;
}
- /** Returns the style class attribute. */
+ /**
+ * Returns the style class attribute.
+ */
public String getStyleClass() {
return styleClass;
}
- /** Sets the style id attribute. */
+ /**
+ * Sets the style id attribute.
+ */
public void setStyleId(String styleId) {
this.styleId = styleId;
}
- /** Returns the style id attribute. */
+ /**
+ * Returns the style id attribute.
+ */
public String getStyleId() {
return styleId;
}
- /** Returns the error key attribute. */
+ /**
+ * Returns the error key attribute.
+ */
public String getErrorKey() {
return errorKey;
}
- /** Sets the error key attribute. */
+ /**
+ * Sets the error key attribute.
+ */
public void setErrorKey(String errorKey) {
this.errorKey = errorKey;
}
- /** Returns the error style attribute. */
+ /**
+ * Returns the error style attribute.
+ */
public String getErrorStyle() {
return errorStyle;
}
- /** Sets the error style attribute. */
+ /**
+ * Sets the error style attribute.
+ */
public void setErrorStyle(String errorStyle) {
this.errorStyle = errorStyle;
}
- /** Returns the error style class attribute. */
+ /**
+ * Returns the error style class attribute.
+ */
public String getErrorStyleClass() {
return errorStyleClass;
}
- /** Sets the error style class attribute. */
+ /**
+ * Sets the error style class attribute.
+ */
public void setErrorStyleClass(String errorStyleClass) {
this.errorStyleClass = errorStyleClass;
}
- /** Returns the error style id attribute. */
+ /**
+ * Returns the error style id attribute.
+ */
public String getErrorStyleId() {
return errorStyleId;
}
- /** Sets the error style id attribute. */
+ /**
+ * Sets the error style id attribute.
+ */
public void setErrorStyleId(String errorStyleId) {
this.errorStyleId = errorStyleId;
}
// Other Common Elements
- /** Returns the alternate text attribute. */
+ /**
+ * Returns the alternate text attribute.
+ */
public String getAlt() {
return alt;
}
- /** Sets the alternate text attribute. */
+ /**
+ * Sets the alternate text attribute.
+ */
public void setAlt(String alt) {
this.alt = alt;
}
- /** Returns the message resources key of the alternate text. */
+ /**
+ * Returns the message resources key of the alternate text.
+ */
public String getAltKey() {
return altKey;
}
- /** Sets the message resources key of the alternate text. */
+ /**
+ * Sets the message resources key of the alternate text.
+ */
public void setAltKey(String altKey) {
this.altKey = altKey;
}
- /** Returns the name of the message resources bundle to use. */
+ /**
+ * Returns the name of the message resources bundle to use.
+ */
public String getBundle() {
return bundle;
}
- /** Sets the name of the message resources bundle to use. */
+ /**
+ * Sets the name of the message resources bundle to use.
+ */
public void setBundle(String bundle) {
this.bundle = bundle;
}
- /** Returns the name of the session attribute for our locale. */
+ /**
+ * Returns the name of the session attribute for our locale.
+ */
public String getLocale() {
return locale;
}
- /** Sets the name of the session attribute for our locale. */
+ /**
+ * Sets the name of the session attribute for our locale.
+ */
public void setLocale(String locale) {
this.locale = locale;
}
- /** Returns the advisory title attribute. */
+ /**
+ * Returns the advisory title attribute.
+ */
public String getTitle() {
return title;
}
- /** Sets the advisory title attribute. */
+ /**
+ * Sets the advisory title attribute.
+ */
public void setTitle(String title) {
this.title = title;
}
- /** Returns the message resources key of the advisory title. */
+ /**
+ * Returns the message resources key of the advisory title.
+ */
public String getTitleKey() {
return titleKey;
}
- /** Sets the message resources key of the advisory title. */
+ /**
+ * Sets the message resources key of the advisory title.
+ */
public void setTitleKey(String titleKey) {
this.titleKey = titleKey;
}
@@ -534,7 +732,6 @@
* Release any acquired resources.
*/
public void release() {
-
super.release();
accesskey = null;
alt = null;
@@ -568,7 +765,6 @@
tabindex = null;
title = null;
titleKey = null;
-
}
// ------------------------------------------------------ Protected Methods
@@ -578,16 +774,16 @@
* key, if any; otherwise return <code>null</code>.
*
* @param literal Literal text value or <code>null</code>
- * @param key Message resources key or <code>null</code>
- *
- * @exception JspException if both arguments are non-null
+ * @param key Message resources key or <code>null</code>
+ * @throws JspException if both arguments are non-null
*/
- protected String message(String literal, String key) throws JspException {
-
+ protected String message(String literal, String key)
+ throws JspException {
if (literal != null) {
if (key != null) {
JspException e =
new JspException(messages.getMessage("common.both"));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
} else {
@@ -595,28 +791,18 @@
}
} else {
if (key != null) {
- return TagUtils.getInstance().message(
- pageContext,
- getBundle(),
- getLocale(),
- key);
+ return TagUtils.getInstance().message(pageContext, getBundle(),
+ getLocale(), key);
} else {
return null;
}
}
-
}
- private Class loopTagSupportClass = null;
- private Method loopTagSupportGetStatus = null;
- private Class loopTagStatusClass = null;
- private Method loopTagStatusGetIndex = null;
- private boolean triedJstlInit = false;
- private boolean triedJstlSuccess = false;
-
private Integer getJstlLoopIndex() {
if (!triedJstlInit) {
triedJstlInit = true;
+
try {
loopTagSupportClass =
RequestUtils.applicationClass(
@@ -633,7 +819,6 @@
loopTagStatusClass.getDeclaredMethod("getIndex", null);
triedJstlSuccess = true;
-
} catch (ClassNotFoundException ex) {
// These just mean that JSTL isn't loaded, so ignore
} catch (NoSuchMethodException ex) {
@@ -642,42 +827,41 @@
if (triedJstlSuccess) {
try {
- Object loopTag = findAncestorWithClass(this, loopTagSupportClass);
+ Object loopTag =
+ findAncestorWithClass(this, loopTagSupportClass);
+
if (loopTag == null) {
return null;
}
Object status = loopTagSupportGetStatus.invoke(loopTag, null);
- return (Integer) loopTagStatusGetIndex.invoke(status, null);
+ return (Integer) loopTagStatusGetIndex.invoke(status, null);
} catch (IllegalAccessException ex) {
log.error(ex.getMessage(), ex);
-
} catch (IllegalArgumentException ex) {
log.error(ex.getMessage(), ex);
-
} catch (InvocationTargetException ex) {
log.error(ex.getMessage(), ex);
-
} catch (NullPointerException ex) {
log.error(ex.getMessage(), ex);
-
} catch (ExceptionInInitializerError ex) {
log.error(ex.getMessage(), ex);
}
}
+
return null;
}
/**
- * Appends bean name with index in brackets for tags with
- * 'true' value in 'indexed' attribute.
- * @param handlers The StringBuffer that output will be appended to.
- * @exception JspException if 'indexed' tag used outside of iterate tag.
+ * Appends bean name with index in brackets for tags with 'true' value in
+ * 'indexed' attribute.
+ *
+ * @param handlers The StringBuffer that output will be appended to.
+ * @throws JspException if 'indexed' tag used outside of iterate tag.
*/
protected void prepareIndex(StringBuffer handlers, String name)
throws JspException {
-
if (name != null) {
handlers.append(name);
}
@@ -692,120 +876,133 @@
}
/**
- * Returns the index value for tags with 'true' value in 'indexed' attribute.
- * @return the index value.
- * @exception JspException if 'indexed' tag used outside of iterate tag.
+ * Returns the index value for tags with 'true' value in 'indexed'
+ * attribute.
+ *
+ * @return the index value.
+ * @throws JspException if 'indexed' tag used outside of iterate tag.
*/
- protected int getIndexValue() throws JspException {
-
+ protected int getIndexValue()
+ throws JspException {
// look for outer iterate tag
IterateTag iterateTag =
(IterateTag) findAncestorWithClass(this, IterateTag.class);
+
if (iterateTag != null) {
return iterateTag.getIndex();
}
// Look for JSTL loops
Integer i = getJstlLoopIndex();
+
if (i != null) {
return i.intValue();
}
// this tag should be nested in an IterateTag or JSTL loop tag, if it's not, throw exception
JspException e =
- new JspException(messages.getMessage("indexed.noEnclosingIterate"));
+ new JspException(messages.getMessage("indexed.noEnclosingIterate"));
+
TagUtils.getInstance().saveException(pageContext, e);
throw e;
-
}
/**
- * Prepares the style attributes for inclusion in the component's HTML tag.
+ * Prepares the style attributes for inclusion in the component's HTML
+ * tag.
+ *
* @return The prepared String for inclusion in the HTML tag.
- * @exception JspException if invalid attributes are specified
+ * @throws JspException if invalid attributes are specified
*/
- protected String prepareStyles() throws JspException {
-
+ protected String prepareStyles()
+ throws JspException {
StringBuffer styles = new StringBuffer();
boolean errorsExist = doErrorsExist();
- if (errorsExist && getErrorStyleId() != null) {
- prepareAttribute(styles , "id", getErrorStyleId());
+ if (errorsExist && (getErrorStyleId() != null)) {
+ prepareAttribute(styles, "id", getErrorStyleId());
} else {
- prepareAttribute(styles , "id", getStyleId());
+ prepareAttribute(styles, "id", getStyleId());
}
- if (errorsExist && getErrorStyle() != null) {
- prepareAttribute(styles , "style", getErrorStyle());
+ if (errorsExist && (getErrorStyle() != null)) {
+ prepareAttribute(styles, "style", getErrorStyle());
} else {
- prepareAttribute(styles , "style", getStyle());
+ prepareAttribute(styles, "style", getStyle());
}
- if (errorsExist && getErrorStyleClass() != null) {
- prepareAttribute(styles , "class", getErrorStyleClass());
+ if (errorsExist && (getErrorStyleClass() != null)) {
+ prepareAttribute(styles, "class", getErrorStyleClass());
} else {
- prepareAttribute(styles , "class", getStyleClass());
+ prepareAttribute(styles, "class", getStyleClass());
}
- prepareAttribute(styles , "title", message(getTitle(), getTitleKey()));
- prepareAttribute(styles , "alt", message(getAlt(), getAltKey()));
+ prepareAttribute(styles, "title", message(getTitle(), getTitleKey()));
+ prepareAttribute(styles, "alt", message(getAlt(), getAltKey()));
return styles.toString();
-
}
/**
* Determine if there are errors for the component.
+ *
* @return Whether errors exist.
*/
- protected boolean doErrorsExist() throws JspException {
-
+ protected boolean doErrorsExist()
+ throws JspException {
boolean errorsExist = false;
- if (getErrorStyleId() != null ||
- getErrorStyle() != null ||
- getErrorStyleClass() != null) {
+ if ((getErrorStyleId() != null) || (getErrorStyle() != null)
+ || (getErrorStyleClass() != null)) {
String actualName = prepareName();
+
if (actualName != null) {
- ActionMessages errors = TagUtils.getInstance()
- .getActionMessages(pageContext,
- errorKey);
- errorsExist = (errors != null && errors.size(actualName) > 0);
+ ActionMessages errors =
+ TagUtils.getInstance().getActionMessages(pageContext,
+ errorKey);
+
+ errorsExist = ((errors != null)
+ && (errors.size(actualName) > 0));
}
}
- return errorsExist;
+ return errorsExist;
}
/**
* Prepares the actual name of the component.
+ *
* @return The actual component name.
*/
- protected String prepareName() throws JspException {
+ protected String prepareName()
+ throws JspException {
return null;
}
/**
* Prepares the event handlers for inclusion in the component's HTML tag.
+ *
* @return The prepared String for inclusion in the HTML tag.
*/
protected String prepareEventHandlers() {
StringBuffer handlers = new StringBuffer();
+
prepareMouseEvents(handlers);
prepareKeyEvents(handlers);
prepareTextEvents(handlers);
prepareFocusEvents(handlers);
+
return handlers.toString();
}
/**
* Prepares the mouse event handlers, appending them to the the given
* StringBuffer.
+ *
* @param handlers The StringBuffer that output will be appended to.
*/
protected void prepareMouseEvents(StringBuffer handlers) {
-
prepareAttribute(handlers, "onclick", getOnclick());
prepareAttribute(handlers, "ondblclick", getOndblclick());
prepareAttribute(handlers, "onmouseover", getOnmouseover());
@@ -813,55 +1010,55 @@
prepareAttribute(handlers, "onmousemove", getOnmousemove());
prepareAttribute(handlers, "onmousedown", getOnmousedown());
prepareAttribute(handlers, "onmouseup", getOnmouseup());
-
}
/**
* Prepares the keyboard event handlers, appending them to the the given
* StringBuffer.
+ *
* @param handlers The StringBuffer that output will be appended to.
*/
protected void prepareKeyEvents(StringBuffer handlers) {
-
prepareAttribute(handlers, "onkeydown", getOnkeydown());
prepareAttribute(handlers, "onkeyup", getOnkeyup());
prepareAttribute(handlers, "onkeypress", getOnkeypress());
-
}
/**
* Prepares the text event handlers, appending them to the the given
* StringBuffer.
+ *
* @param handlers The StringBuffer that output will be appended to.
*/
protected void prepareTextEvents(StringBuffer handlers) {
-
prepareAttribute(handlers, "onselect", getOnselect());
prepareAttribute(handlers, "onchange", getOnchange());
-
}
/**
* Prepares the focus event handlers, appending them to the the given
* StringBuffer.
+ *
* @param handlers The StringBuffer that output will be appended to.
*/
protected void prepareFocusEvents(StringBuffer handlers) {
-
prepareAttribute(handlers, "onblur", getOnblur());
prepareAttribute(handlers, "onfocus", getOnfocus());
// Get the parent FormTag (if necessary)
FormTag formTag = null;
- if ((doDisabled && !getDisabled()) ||
- (doReadonly && !getReadonly())) {
- formTag = (FormTag)pageContext.getAttribute(Constants.FORM_KEY,
- PageContext.REQUEST_SCOPE);
+
+ if ((doDisabled && !getDisabled()) || (doReadonly && !getReadonly())) {
+ formTag =
+ (FormTag) pageContext.getAttribute(Constants.FORM_KEY,
+ PageContext.REQUEST_SCOPE);
}
// Format Disabled
if (doDisabled) {
- boolean formDisabled = formTag == null ? false : formTag.isDisabled();
+ boolean formDisabled =
+ (formTag == null) ? false : formTag.isDisabled();
+
if (formDisabled || getDisabled()) {
handlers.append(" disabled=\"disabled\"");
}
@@ -869,28 +1066,31 @@
// Format Read Only
if (doReadonly) {
- boolean formReadOnly = formTag == null ? false : formTag.isReadonly();
+ boolean formReadOnly =
+ (formTag == null) ? false : formTag.isReadonly();
+
if (formReadOnly || getReadonly()) {
handlers.append(" readonly=\"readonly\"");
}
}
-
}
/**
- * 'Hook' to enable tags to be extended and
- * additional attributes added.
+ * '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.
+ * 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) {
+ protected void prepareAttribute(StringBuffer handlers, String name,
+ Object value) {
if (value != null) {
handlers.append(" ");
handlers.append(name);
@@ -901,10 +1101,11 @@
}
/**
- * Allows HTML tags to find out if they're nested within an %lt;html:html> tag that
- * has xhtml set to true.
- * @return true if the tag is nested within an html tag with xhtml set to true, false
- * otherwise.
+ * Allows HTML tags to find out if they're nested within an
+ * %lt;html:html> tag that has xhtml set to true.
+ *
+ * @return true if the tag is nested within an html tag with xhtml set to
+ * true, false otherwise.
* @since Struts 1.1
*/
protected boolean isXhtml() {
@@ -912,8 +1113,10 @@
}
/**
- * Returns the closing brace for an input element depending on xhtml status. The tag
- * must be nested within an %lt;html:html> tag that has xhtml set to true.
+ * Returns the closing brace for an input element depending on xhtml
+ * status. The tag must be nested within an %lt;html:html> tag that
+ * has xhtml set to true.
+ *
* @return String - > if xhtml is false, /> if xhtml is true
* @since Struts 1.1
*/
@@ -922,9 +1125,9 @@
}
/**
- * Searches all scopes for the bean and calls BeanUtils.getProperty() with the
- * given arguments and converts any exceptions into JspException.
- *
+ * Searches all scopes for the bean and calls BeanUtils.getProperty() with
+ * the given arguments and converts any exceptions into JspException.
+ *
* @param beanName The name of the object to get the property from.
* @param property The name of the property to get.
* @return The value of the property.
@@ -933,28 +1136,26 @@
*/
protected String lookupProperty(String beanName, String property)
throws JspException {
+ Object bean =
+ TagUtils.getInstance().lookup(this.pageContext, beanName, null);
- Object bean = TagUtils.getInstance().lookup(this.pageContext, beanName, null);
if (bean == null) {
throw new JspException(messages.getMessage("getter.bean", beanName));
}
try {
return BeanUtils.getProperty(bean, property);
-
} catch (IllegalAccessException e) {
- throw new JspException(
- messages.getMessage("getter.access", property, beanName));
-
+ throw new JspException(messages.getMessage("getter.access",
+ property, beanName));
} catch (InvocationTargetException e) {
Throwable t = e.getTargetException();
- throw new JspException(
- messages.getMessage("getter.result", property, t.toString()));
+ throw new JspException(messages.getMessage("getter.result",
+ property, t.toString()));
} catch (NoSuchMethodException e) {
- throw new JspException(
- messages.getMessage("getter.method", property, beanName));
+ throw new JspException(messages.getMessage("getter.method",
+ property, beanName));
}
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseInputTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseInputTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseInputTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseInputTag.java Fri Feb 10 13:01:28 2006
@@ -1,38 +1,45 @@
/*
- * $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.util.MessageResources;
+import javax.servlet.jsp.JspException;
+
/**
* Abstract base class for the various input tags.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
public abstract class BaseInputTag extends BaseHandlerTag {
+ /**
+ * The message resources for this package.
+ */
+ protected static MessageResources messages =
+ MessageResources.getMessageResources(Constants.Package
+ + ".LocalStrings");
// ----------------------------------------------------- Instance Variables
/**
- * The number of character columns for this field, or negative
- * for no limit.
+ * The number of character columns for this field, or negative for no
+ * limit.
*/
protected String cols = null;
@@ -42,12 +49,6 @@
protected String maxlength = null;
/**
- * The message resources for this package.
- */
- protected static MessageResources messages =
- MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
-
- /**
* The name of the field (and associated property) being processed.
*/
protected String property = null;
@@ -69,7 +70,6 @@
protected String name = Constants.BEAN_KEY;
// ------------------------------------------------------------- Properties
-
public String getName() {
return (this.name);
}
@@ -82,9 +82,7 @@
* Return the number of columns for this field.
*/
public String getCols() {
-
return (this.cols);
-
}
/**
@@ -93,18 +91,14 @@
* @param cols The new number of columns
*/
public void setCols(String cols) {
-
this.cols = cols;
-
}
/**
* Return the maximum length allowed.
*/
public String getMaxlength() {
-
return (this.maxlength);
-
}
/**
@@ -113,18 +107,14 @@
* @param maxlength The new maximum length
*/
public void setMaxlength(String maxlength) {
-
this.maxlength = maxlength;
-
}
/**
* Return the property name.
*/
public String getProperty() {
-
return (this.property);
-
}
/**
@@ -133,18 +123,14 @@
* @param property The new property name
*/
public void setProperty(String property) {
-
this.property = property;
-
}
/**
* Return the number of rows for this field.
*/
public String getRows() {
-
return (this.rows);
-
}
/**
@@ -153,18 +139,14 @@
* @param rows The new number of rows
*/
public void setRows(String rows) {
-
this.rows = rows;
-
}
/**
* Return the size of this field (synonym for <code>getCols()</code>).
*/
public String getSize() {
-
return (getCols());
-
}
/**
@@ -173,83 +155,75 @@
* @param size The new size
*/
public void setSize(String size) {
-
setCols(size);
-
}
/**
* Return the field value (if any).
*/
public String getValue() {
-
return (this.value);
-
}
/**
* Set the field value (if any).
*
* @param value The new field value, or <code>null</code> to retrieve the
- * corresponding property from the bean
+ * corresponding property from the bean
*/
public void setValue(String value) {
-
this.value = value;
-
}
// --------------------------------------------------------- Public Methods
/**
- * Process the start of this tag. The default implementation does nothing.
+ * Process the start of this tag. The default implementation does
+ * nothing.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
-
return (EVAL_BODY_TAG);
-
}
/**
* Process the end of this tag. The default implementation does nothing.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
-
return (EVAL_PAGE);
-
}
/**
* 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();
name = Constants.BEAN_KEY;
cols = null;
@@ -257,7 +231,5 @@
property = null;
rows = null;
value = null;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/BaseTag.java Fri Feb 10 13:01:28 2006
@@ -1,25 +1,26 @@
/*
- * $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.io.IOException;
-import java.util.StringTokenizer;
+import org.apache.struts.Globals;
+import org.apache.struts.taglib.TagUtils;
+import org.apache.struts.util.MessageResources;
+import org.apache.struts.util.RequestUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@@ -27,32 +28,29 @@
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.TagSupport;
-import org.apache.struts.Globals;
-import org.apache.struts.taglib.TagUtils;
-import org.apache.struts.util.MessageResources;
-import org.apache.struts.util.RequestUtils;
+import java.io.IOException;
+
+import java.util.StringTokenizer;
/**
- * Renders an HTML <base> element with an href
- * attribute pointing to the absolute location of the enclosing JSP page. This
- * tag is only valid when nested inside a head tag body. The presence
- * of this tag allows the browser to resolve relative URL's to images,
- * CSS stylesheets and other resources in a manner independent of the URL
- * used to call the ActionServlet.
+ * Renders an HTML <base> element with an href attribute pointing to the
+ * absolute location of the enclosing JSP page. This tag is only valid when
+ * nested inside a head tag body. The presence of this tag allows the browser
+ * to resolve relative URL's to images, CSS stylesheets and other resources
+ * in a manner independent of the URL used to call the ActionServlet.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2005-09-20 02:29:01 -0400 (Tue, 20 Sep 2005)
+ * $
*/
-
public class BaseTag extends TagSupport {
-
- protected final String REF_SITE = "site";
- protected final String REF_PAGE = "page";
-
/**
* The message resources for this package.
*/
protected static MessageResources messages =
- MessageResources.getMessageResources(Constants.Package + ".LocalStrings");
+ MessageResources.getMessageResources(Constants.Package
+ + ".LocalStrings");
+ protected final String REF_SITE = "site";
+ protected final String REF_PAGE = "page";
/**
* The server name to use instead of request.getServerName().
@@ -68,33 +66,35 @@
* The reference to which the base will created.
*/
protected String ref = REF_PAGE;
-
+
/**
* Gets the reference to which the base will be created
*/
public String getRef() {
- return (this.ref);
+ return (this.ref);
}
-
+
/**
* Sets the reference to which the base will be created.
*
- * @param ref Either "page" to render the base as the jsp path
- * located, or "site" as the application's context
+ * @param ref Either "page" to render the base as the jsp path located, or
+ * "site" as the application's context
*/
public void setRef(String ref) {
if (ref == null) {
throw new IllegalArgumentException("Ref attribute cannot be null");
}
+
ref = ref.toLowerCase();
+
if (ref.equals(REF_PAGE) || ref.equals(REF_SITE)) {
this.ref = ref;
} else {
- throw new IllegalArgumentException("Ref attribute must either be "+
- "'" + REF_PAGE + "' or '" + REF_SITE + "'");
- }
+ throw new IllegalArgumentException("Ref attribute must either be "
+ + "'" + REF_PAGE + "' or '" + REF_SITE + "'");
+ }
}
-
+
public String getTarget() {
return (this.target);
}
@@ -106,89 +106,101 @@
/**
* 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 {
- HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
- String serverName = (this.server == null) ? request.getServerName() : this.server;
-
+ HttpServletRequest request =
+ (HttpServletRequest) pageContext.getRequest();
+ String serverName =
+ (this.server == null) ? request.getServerName() : this.server;
+
int port = request.getServerPort();
String headerHost = request.getHeader("Host");
- if (serverName == null && headerHost != null) {
- StringTokenizer tokenizer = new StringTokenizer(headerHost,":");
+
+ if ((serverName == null) && (headerHost != null)) {
+ StringTokenizer tokenizer = new StringTokenizer(headerHost, ":");
+
serverName = tokenizer.nextToken();
+
if (tokenizer.hasMoreTokens()) {
String portS = tokenizer.nextToken();
+
try {
port = Integer.parseInt(portS);
- } catch (Exception e){
+ } catch (Exception e) {
port = 80;
}
} else {
port = 80;
}
}
- String baseTag = renderBaseElement(
- request.getScheme(),
- serverName,
- port,
- request.getRequestURI());
+
+ String baseTag =
+ renderBaseElement(request.getScheme(), serverName, port,
+ request.getRequestURI());
JspWriter out = pageContext.getOut();
+
try {
out.write(baseTag);
} catch (IOException e) {
- pageContext.setAttribute(Globals.EXCEPTION_KEY, e, PageContext.REQUEST_SCOPE);
+ pageContext.setAttribute(Globals.EXCEPTION_KEY, e,
+ PageContext.REQUEST_SCOPE);
throw new JspException(messages.getMessage("common.io", e.toString()));
}
-
+
return EVAL_BODY_INCLUDE;
}
/**
- * Render a fully formed HTML <base> element and return it as a String.
- * @param scheme The scheme used in the url (ie. http or https).
+ * Render a fully formed HTML <base> element and return it as a
+ * String.
+ *
+ * @param scheme The scheme used in the url (ie. http or https).
* @param serverName
* @param port
- * @param uri The portion of the url from the protocol name up to the query
- * string.
+ * @param uri The portion of the url from the protocol name up to
+ * the query string.
* @return String An HTML <base> element.
* @since Struts 1.1
*/
- protected String renderBaseElement(
- String scheme,
- String serverName,
- int port,
- String uri) {
-
+ protected String renderBaseElement(String scheme, String serverName,
+ int port, String uri) {
StringBuffer tag = new StringBuffer("<base href=\"");
- if(ref.equals(REF_SITE)) {
- StringBuffer contextBase = new StringBuffer(((HttpServletRequest)pageContext.getRequest()).getContextPath());
+
+ if (ref.equals(REF_SITE)) {
+ StringBuffer contextBase =
+ new StringBuffer(((HttpServletRequest) pageContext.getRequest())
+ .getContextPath());
+
contextBase.append("/");
- tag.append(RequestUtils.createServerUriStringBuffer(scheme,serverName,port,contextBase.toString()).toString());
- }
- else {
- tag.append(RequestUtils.createServerUriStringBuffer(scheme,serverName,port,uri).toString());
+ tag.append(RequestUtils.createServerUriStringBuffer(scheme,
+ serverName, port, contextBase.toString()).toString());
+ } else {
+ tag.append(RequestUtils.createServerUriStringBuffer(scheme,
+ serverName, port, uri).toString());
}
+
tag.append("\"");
-
+
if (this.target != null) {
tag.append(" target=\"");
tag.append(this.target);
tag.append("\"");
}
-
+
if (TagUtils.getInstance().isXhtml(this.pageContext)) {
tag.append(" />");
} else {
tag.append(">");
}
-
+
return tag.toString();
}
-
+
/**
* Returns the server.
+ *
* @return String
*/
public String getServer() {
@@ -197,10 +209,10 @@
/**
* Sets the server.
+ *
* @param server The server to set
*/
public void setServer(String server) {
this.server = server;
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ButtonTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ButtonTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ButtonTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/ButtonTag.java Fri Feb 10 13:01:28 2006
@@ -1,30 +1,30 @@
/*
- * $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;
+
/**
* Renders an HTML BUTTON tag within the Struts framework.
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-17 02:40:12 -0400 (Sun, 17 Oct 2004)
+ * $
*/
public class ButtonTag extends SubmitTag {
-
/**
* Render the opening element.
*
@@ -42,6 +42,4 @@
protected String getDefaultValue() {
return "Click";
}
-
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CancelTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CancelTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CancelTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CancelTag.java Fri Feb 10 13:01:28 2006
@@ -1,52 +1,45 @@
/*
- * $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;
-
/**
* Tag for input fields of type "cancel".
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-17 02:40:12 -0400 (Sun, 17 Oct 2004)
+ * $
*/
-
public class CancelTag extends SubmitTag {
-
-
- // ------------------------------------------------------------- Properties
-
-
- /** Returns the onClick event handler. */
- public String getOnclick() {
- return super.getOnclick() == null ? "bCancel=true;"
- : super.getOnclick();
- }
-
// --------------------------------------------------------- Constructor
-
public CancelTag() {
-
super();
property = Constants.CANCEL_PROPERTY;
+ }
+ // ------------------------------------------------------------- Properties
+
+ /**
+ * Returns the onClick event handler.
+ */
+ public String getOnclick() {
+ return (super.getOnclick() == null) ? "bCancel=true;" : super
+ .getOnclick();
}
// --------------------------------------------------------- Protected Methods
@@ -62,9 +55,11 @@
/**
* Prepare the name element
+ *
* @return The element name.
*/
- protected String prepareName() throws JspException {
+ protected String prepareName()
+ throws JspException {
return property;
}
@@ -81,10 +76,7 @@
* Release any acquired resources.
*/
public void release() {
-
super.release();
property = Constants.CANCEL_PROPERTY;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CheckboxTag.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CheckboxTag.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CheckboxTag.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/CheckboxTag.java Fri Feb 10 13:01:28 2006
@@ -1,56 +1,48 @@
/*
- * $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 "checkbox".
*
- * @version $Rev$ $Date$
+ * @version $Rev$ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
+ * $
*/
public class CheckboxTag 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 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 property name for this field.
*/
@@ -66,15 +58,21 @@
*/
protected String value = null;
+ public String getName() {
+ return (this.name);
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
// ------------------------------------------------------------- Properties
/**
* Return the property name.
*/
public String getProperty() {
-
return (this.property);
-
}
/**
@@ -83,18 +81,14 @@
* @param property The new property name
*/
public void setProperty(String property) {
-
this.property = property;
-
}
/**
* Return the server value.
*/
public String getValue() {
-
- return value == null ? "on" : value;
-
+ return (value == null) ? "on" : value;
}
/**
@@ -103,29 +97,27 @@
* @param value The new server value
*/
public void setValue(String value) {
-
this.value = value;
-
}
// --------------------------------------------------------- Public Methods
/**
- * Generate the required input tag.
- * <p>
- * Support for indexed property since Struts 1.1
+ * Generate the required input 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 {
-
// Create an appropriate "input" element based on our parameters
StringBuffer results = new StringBuffer("<input type=\"checkbox\"");
+
prepareAttribute(results, "name", prepareName());
prepareAttribute(results, "accesskey", getAccesskey());
prepareAttribute(results, "tabindex", getTabindex());
prepareAttribute(results, "value", getValue());
+
if (isChecked()) {
results.append(" checked=\"checked\"");
}
@@ -140,59 +132,58 @@
// Continue processing this page
this.text = null;
- return (EVAL_BODY_TAG);
+ return (EVAL_BODY_TAG);
}
-
+
/**
* Determines if the checkbox should be checked.
+ *
* @return true if checked="checked" should be rendered.
* @throws JspException
* @since Struts 1.2
*/
- protected boolean isChecked() throws JspException {
- Object result =
- TagUtils.getInstance().lookup(pageContext, name, property, null);
-
- if (result == null) {
- result = "";
- }
-
- result = result.toString();
-
- String checked = (String) result;
- return (
- checked.equalsIgnoreCase(this.value)
- || checked.equalsIgnoreCase("true")
- || checked.equalsIgnoreCase("yes")
- || checked.equalsIgnoreCase("on"));
+ protected boolean isChecked()
+ throws JspException {
+ Object result =
+ TagUtils.getInstance().lookup(pageContext, name, property, null);
+
+ if (result == null) {
+ result = "";
+ }
- }
+ result = result.toString();
+
+ String checked = (String) result;
+
+ return (checked.equalsIgnoreCase(this.value)
+ || checked.equalsIgnoreCase("true") || checked.equalsIgnoreCase("yes")
+ || checked.equalsIgnoreCase("on"));
+ }
/**
* 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 remainder of this page normally.
*
- * @exception JspException if a JSP exception has occurred
+ * @throws JspException if a JSP exception has occurred
*/
public int doEndTag() throws JspException {
-
// Render any description for this checkbox
if (text != null) {
TagUtils.getInstance().write(pageContext, text);
@@ -200,43 +191,40 @@
// Evaluate the remainder of this page
return (EVAL_PAGE);
-
}
-
/**
* 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();
name = Constants.BEAN_KEY;
property = null;
text = null;
value = null;
-
}
-
}
Modified: struts/taglib/trunk/src/java/org/apache/struts/taglib/html/Constants.java
URL: http://svn.apache.org/viewcvs/struts/taglib/trunk/src/java/org/apache/struts/taglib/html/Constants.java?rev=376841&r1=376840&r2=376841&view=diff
==============================================================================
--- struts/taglib/trunk/src/java/org/apache/struts/taglib/html/Constants.java (original)
+++ struts/taglib/trunk/src/java/org/apache/struts/taglib/html/Constants.java Fri Feb 10 13:01:28 2006
@@ -1,73 +1,60 @@
/*
- * $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;
/**
* Manifest constants for this package.
*/
-
public class Constants {
-
-
/**
* The name of this package.
*/
public static final String Package = "org.apache.struts.taglib.html";
-
/**
* The attribute key for the bean our form is related to.
*/
public static final String BEAN_KEY = Package + ".BEAN";
-
/**
* The property under which a Cancel button press is reported.
*/
public static final String CANCEL_PROPERTY = Package + ".CANCEL";
-
/**
* The property under which a Cancel button press is reported, if the
* Cancel button is rendered as an image.
*/
public static final String CANCEL_PROPERTY_X = Package + ".CANCEL.x";
-
/**
* The attribute key for the form tag itself.
*/
public static final String FORM_KEY = Package + ".FORM";
-
/**
* The attribute key for the select tag itself.
*/
public static final String SELECT_KEY = Package + ".SELECT";
-
/**
* The property under which a transaction token is reported.
*/
public static final String TOKEN_KEY = Package + ".TOKEN";
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org