Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Nightly Builds
-
None
-
None
-
None
-
Operating System: other
Platform: Other
-
18297
Description
I would only report this bug with knowledge that an inconsistency exists in the
BeanUtils converters. When using the converter IntegerArrayConverter, the
converter attempts to parse a String[] to an int[], however it makes no attempt
to do the far easier conversion from int[] to String[] in StringArrayConverter.
This happens to be a very important conversion since multiple select boxes in
html forms must be set at a string array even though the model often transfers
data to the form as an int[]. The two conversions are equally important and it
is, in my mind, a missing feature that the conversion exists in one case and not
in the other. The follow is the necessary patch to add this convertor.
— StringArrayConverter.java.orig 2003-03-21 04:43:17.000000000 -0500
+++ StringArrayConverter.java 2003-03-21 04:43:20.000000000 -0500
@@ -113,6 +113,10 @@
// ------------------------------------------------------- Static Variables
+ /**
+ * <p> Model object for int arrays.</p>
+ */
+ private static int ints[] = new int[0];
/**
- <p>Model object for type comparisons.</p>
@@ -149,6 +153,19 @@
return (value);
}
+ // Deal with the input value as an int array
+ if (ints.getClass() == value.getClass())
+ {
+ int[] values = (int[]) value;
+ String[] results = new String[values.length];
+ for (int i = 0; i < values.length; i++)
+
+
+ return (results);
+ }
+
// Parse the input value as a String into elements
// and convert to the appropriate type
try {
As you can see, the added functionality is copied almost directly from
IntegerArrayConverter.