craigmcc 01/06/01 11:45:10
Modified: src/share/org/apache/struts/util Tag: STRUTS_1_0_BRANCH
RequestUtils.java
web/exercise-taglib Tag: STRUTS_1_0_BRANCH html-link.jsp
Log:
Update RequestUtils.computeURL() so that it will properly deal with
non-String objects in the Map specified by "name" (or "name" and
"property"). The appropriate toString() will be called.
Update the new html-link.jsp test page to exercise this functionality.
This fixes the problem reported in Bugzilla #1891 -- also need to update
the docs to reflect the loosened restrictions on what can be in the Map.
PR: Bugzilla #1891
Submitted by: Levi Cook <[EMAIL PROTECTED]>
Revision Changes Path
No revision
No revision
1.14.2.1 +14 -5
jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java
Index: RequestUtils.java
===================================================================
RCS file:
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v
retrieving revision 1.14
retrieving revision 1.14.2.1
diff -u -r1.14 -r1.14.2.1
--- RequestUtils.java 2001/05/12 22:35:43 1.14
+++ RequestUtils.java 2001/06/01 18:45:03 1.14.2.1
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.14
2001/05/12 22:35:43 craigmcc Exp $
- * $Revision: 1.14 $
- * $Date: 2001/05/12 22:35:43 $
+ * $Header:
/home/cvs/jakarta-struts/src/share/org/apache/struts/util/RequestUtils.java,v 1.14.2.1
2001/06/01 18:45:03 craigmcc Exp $
+ * $Revision: 1.14.2.1 $
+ * $Date: 2001/06/01 18:45:03 $
*
* ====================================================================
*
@@ -95,7 +95,7 @@
* in the Struts controller framework.
*
* @author Craig R. McClanahan
- * @version $Revision: 1.14 $ $Date: 2001/05/12 22:35:43 $
+ * @version $Revision: 1.14.2.1 $ $Date: 2001/06/01 18:45:03 $
*/
public class RequestUtils {
@@ -376,7 +376,7 @@
url.append(URLEncoder.encode(key));
url.append('=');
url.append(URLEncoder.encode((String) value));
- } else /* if (value instanceof String[]) */ {
+ } else if (value instanceof String[]) {
String values[] = (String[]) value;
for (int i = 0; i < values.length; i++) {
if (!question) {
@@ -388,6 +388,15 @@
url.append('=');
url.append(URLEncoder.encode(values[i]));
}
+ } else /* Convert other objects to a string */ {
+ if (!question) {
+ url.append('?');
+ question = true;
+ } else
+ url.append('&');
+ url.append(URLEncoder.encode(key));
+ url.append('=');
+ url.append(URLEncoder.encode(value.toString()));
}
}
No revision
No revision
1.1.2.2 +13 -3 jakarta-struts/web/exercise-taglib/Attic/html-link.jsp
Index: html-link.jsp
===================================================================
RCS file: /home/cvs/jakarta-struts/web/exercise-taglib/Attic/html-link.jsp,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- html-link.jsp 2001/06/01 18:14:30 1.1.2.1
+++ html-link.jsp 2001/06/01 18:45:08 1.1.2.2
@@ -9,8 +9,10 @@
String newValue = "New string value";
pageContext.setAttribute("newValue", newValue);
java.util.HashMap newValues = new java.util.HashMap();
- newValues.put("floatProperty", "444.0");
- newValues.put("intProperty", "555");
+ newValues.put("floatProperty", new Float(444.0));
+ newValues.put("intProperty", new Integer(555));
+ newValues.put("stringArray", new String[]
+ { "Value 1", "Value 2", "Value 3" });
pageContext.setAttribute("newValues", newValues);
%>
</head>
@@ -66,6 +68,14 @@
</tr>
<tr>
+ <th align="right">stringArray</th>
+ <td align="left" colspan="3">
+ <html:text property="stringArray[0]" size="16"/>
+ <html:text property="stringArray[1]" size="16"/>
+ </td>
+ </tr>
+
+ <tr>
<th colspan="4" align="center">
Hyperlinks To Be Tested
</th>
@@ -110,7 +120,7 @@
<td colspan="4" align="center">
<html:link page="/html-link.do"
name="newValues">
- Float and int via name (Map)
+ Float, int, and stringArray via name (Map)
</html:link>
</td>
</tr>