You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by dg...@apache.org on 2003/07/04 22:23:10 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html BaseFieldTag.java
dgraham 2003/07/04 13:23:10
Modified: src/share/org/apache/struts/taglib/html BaseFieldTag.java
Log:
Refactored input element generation into new renderInputElement() method
called from doStartTag().
Revision Changes Path
1.18 +36 -19 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- BaseFieldTag.java 16 Nov 2002 06:05:21 -0000 1.17
+++ BaseFieldTag.java 4 Jul 2003 20:23:10 -0000 1.18
@@ -134,14 +134,27 @@
* @exception JspException if a JSP exception has occurred
*/
public int doStartTag() throws JspException {
+
+ ResponseUtils.write(this.pageContext, this.renderInputElement());
- // Create an appropriate "input" element based on our parameters
+ return (EVAL_BODY_TAG);
+
+ }
+
+ /**
+ * Renders a fully formed <input> element.
+ * @throws JspException
+ * @since Struts 1.2
+ */
+ protected String renderInputElement() throws JspException {
StringBuffer results = new StringBuffer("<input type=\"");
- results.append(type);
+ results.append(this.type);
results.append("\" name=\"");
- // * @since Struts 1.1
- if (indexed)
- prepareIndex(results, name);
+
+ if (indexed) {
+ this.prepareIndex(results, name);
+ }
+
results.append(property);
results.append("\"");
if (accesskey != null) {
@@ -149,46 +162,50 @@
results.append(accesskey);
results.append("\"");
}
+
if (accept != null) {
results.append(" accept=\"");
results.append(accept);
results.append("\"");
}
+
if (maxlength != null) {
results.append(" maxlength=\"");
results.append(maxlength);
results.append("\"");
}
+
if (cols != null) {
results.append(" size=\"");
results.append(cols);
results.append("\"");
}
+
if (tabindex != null) {
results.append(" tabindex=\"");
results.append(tabindex);
results.append("\"");
}
+
results.append(" value=\"");
if (value != null) {
results.append(ResponseUtils.filter(value));
+
} else if (redisplay || !"password".equals(type)) {
Object value = RequestUtils.lookup(pageContext, name, property, null);
- if (value == null)
+ if (value == null) {
value = "";
+ }
+
results.append(ResponseUtils.filter(value.toString()));
}
- results.append("\"");
- results.append(prepareEventHandlers());
- results.append(prepareStyles());
- results.append(getElementClose());
-
- // Print this field to our output writer
- ResponseUtils.write(pageContext, results.toString());
- // Continue processing this page
- return (EVAL_BODY_TAG);
+ results.append("\"");
+ results.append(this.prepareEventHandlers());
+ results.append(this.prepareStyles());
+ results.append(this.getElementClose());
+ return results.toString();
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org