cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "neil" <nba...@aisoftware.com.au>
Subject patch to fix NullPointerException from <xsp-request:get-parameter-values
Date Tue, 04 Jun 2002 05:47:51 GMT
I've got a form that posts multiple values for a request parameter (multiple
instances of <input type="text" name="paramName"/>).

request.getParameterValues() returns a String[] with an element for each
posted value.
If nothing is entered into into one of the text fields the corresponding
element in the String[] is null, but this isn't handled by
<xsp-request:get-parameter-values. The stacktrace is included in the
following patch to fix the problem:


--- XSPRequestHelper.java.1.11	Tue Jun  4 15:32:54 2002
+++ XSPRequestHelper.java	Tue Jun  4 15:05:28 2002
@@ -68,8 +68,19 @@

 /**
  * The <code>Request</code> object helper
+ * <pre>
+ * Modified by Pinnacle Software to fix:
+ *
+ * java.lang.NullPointerException
+ *	at
org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper.data(XSPObj
ectHelper.java:196)
+ *	at
org.apache.cocoon.components.language.markup.xsp.XSPObjectHelper.elementData
(XSPObjectHelper.java:93)
+ *	at
org.apache.cocoon.components.language.markup.xsp.XSPRequestHelper.getParamet
erValues(XSPRequestHelper.java:291)
+ *	at
org.apache.cocoon.www.pinnacle.assetComponents_xsp.generate(C:\jakarta-tomca
t-4.0.4-b3\work\Standalone\localhost\cocoon\cocoon-files\org/apache/cocoon/w
ww/pinnacle\assetComponents_xsp.java:1299)
+ *	at
org.apache.cocoon.generation.ServerPagesGenerator.generate(ServerPagesGenera
tor.java:260)
+ * </pre>
  *
  * @author <a href="mailto:ricardo@apache.org">Ricardo Rocha</a>
+ * @version Modified from Apache's version CVS Id: XSPRequestHelper.java,v
1.11 2002/02/27 05:33:50 vgritsenko Exp
  * @version CVS $Id: XSPRequestHelper.java,v 1.1 2002/06/04 04:52:31 neil
Exp $
  */
 public class XSPRequestHelper {
@@ -278,15 +289,18 @@
         String[] values = request.getParameterValues(name);
         if (values != null) {
             for (int i = 0; i < values.length; i++) {
-                if(form_encoding != null && values[i] != null &&
-                    values[i].length() > 0) {
-                    try {
-                        values[i] = new
String(values[i].getBytes(container_encoding),
-                            form_encoding);
-                    } catch(java.io.UnsupportedEncodingException uee) {
-                        throw new RuntimeException("Unsupported Encoding
Exception: " +
-                            uee.getMessage());
-                    }
+		if (values[i] != null) {
+		    if(form_encoding != null && values[i].length() > 0) {
+			try {
+			    values[i] = new String(values[i].getBytes(container_encoding),
+						   form_encoding);
+			} catch(java.io.UnsupportedEncodingException uee) {
+			    throw new RuntimeException("Unsupported Encoding Exception: " +
+						       uee.getMessage());
+			}
+		    }
+		} else {
+		    values[i] = "";
                 }
                 XSPObjectHelper.elementData(URI, PREFIX, contentHandler,
                     "value", values[i]);


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message