myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Travis <jtra...@p00p.org>
Subject ArrayStoreException in _SharedRendererUtils (with patch)
Date Wed, 12 Oct 2005 20:08:07 GMT
We ran into a problem when dealing with selectMany objects not
too long ago.  There is some incorrect code in the
getConvertedUISelectManyValue method which ends up causing
an ArrayStoreException (Trying to store an Object[] into an
entry in an Object[]).  This happens when we don't know the
object type we're dealing with.  The result prior to the
patch is a stack trace.

This patch fixes it.  BTW -- Some of this code in between
the 2 _SharedRendererUtils was not in sync.  It might be
nice to automate this so that they are never out-of-sync.

-- Jon



Index: share/src/java/org/apache/myfaces/renderkit/ 
_SharedRendererUtils.java
===================================================================
--- share/src/java/org/apache/myfaces/renderkit/ 
_SharedRendererUtils.java      (revision 292567)
+++ share/src/java/org/apache/myfaces/renderkit/ 
_SharedRendererUtils.java      (working copy)
@@ -141,8 +141,10 @@
              // ...but have no idea of expected type
              // --> so let's convert it to an Object array
              int len = submittedValue.length;
-            Object [] convertedValues = (Object []) Array.newInstance(
-                    arrayComponentType==null?Object 
[].class:arrayComponentType,len);
+
+            //Object [] convertedValues = (Object [])  
Array.newInstance(
+            //arrayComponentType==null?Object 
[].class:arrayComponentType,len);
+            Object [] convertedValues = new Object[len];
              for (int i = 0; i < len; i++)
              {
                  convertedValues[i]
Index: api/src/java/javax/faces/component/_SharedRendererUtils.java
===================================================================
--- api/src/java/javax/faces/component/ 
_SharedRendererUtils.java        (revision 292567)
+++ api/src/java/javax/faces/component/ 
_SharedRendererUtils.java        (working copy)
@@ -136,7 +136,8 @@
              // ...but have no idea of expected type
              // --> so let's convert it to an Object array
              int len = submittedValue.length;
-            Object [] convertedValues = (Object []) Array.newInstance 
(arrayComponentType, len);
+            //Object [] convertedValues = (Object [])  
Array.newInstance(arrayComponentType, len);
+            Object[] convertedValues = new Object[len];
              for (int i = 0; i < len; i++)
              {
                  convertedValues[i]




Mime
View raw message