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/11/16 00:08:54 UTC
cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/html BaseFieldTag.java
dgraham 2003/11/15 15:08:54
Modified: src/share/org/apache/struts/taglib/html BaseFieldTag.java
Log:
Added formatValue() method for PR# 24608.
Revision Changes Path
1.22 +30 -13 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.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- BaseFieldTag.java 31 Jul 2003 00:34:15 -0000 1.21
+++ BaseFieldTag.java 15 Nov 2003 23:08:54 -0000 1.22
@@ -7,7 +7,7 @@
*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
+ * Copyright (c) 2001-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -189,23 +189,40 @@
results.append(" value=\"");
if (value != null) {
- results.append(TagUtils.getInstance().filter(value));
+ results.append(this.formatValue(value));
} else if (redisplay || !"password".equals(type)) {
- Object value = TagUtils.getInstance().lookup(pageContext, name, property, null);
- if (value == null) {
- value = "";
- }
-
- results.append(TagUtils.getInstance().filter(value.toString()));
+ Object value =
+ TagUtils.getInstance().lookup(pageContext, name, property, null);
+
+ results.append(this.formatValue(value));
}
- results.append("\"");
+ results.append('"');
results.append(this.prepareEventHandlers());
results.append(this.prepareStyles());
results.append(this.getElementClose());
return results.toString();
+ }
+
+ /**
+ * 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 "".
+ *
+ * @throws JspException if a JSP exception has occurred
+ *
+ * @since Struts 1.2
+ */
+ protected String formatValue(Object value) throws JspException {
+ if (value == null) {
+ return "";
+ }
+
+ return TagUtils.getInstance().filter(value.toString());
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org