commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 9868] New: - BeanUtils.populate() throws IllegalArgumentException when setting indexed property as array.
Date Fri, 14 Jun 2002 14:14:39 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9868>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9868

BeanUtils.populate() throws IllegalArgumentException when setting indexed property as array.

           Summary: BeanUtils.populate() throws IllegalArgumentException
                    when setting indexed property as array.
           Product: Commons
           Version: 1.0 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Bean Utilities
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: jerome.jacobsen@gentootech.com


BeanUtils.populate throws an IllegalArgumentException when setting an indexed 
String property as an array.

For example:

public class TestBean {
    private String stringIndexed[] =
    { "String 0", "String 1", "String 2", "String 3", "String 4" };
    
    public String[] getStringIndexed() {
        return (this.stringIndexed);
    }

    public void setStringIndexed(String value[]) {
        this.stringIndexed = value;
    }

    public String getStringIndexed(int index) {
        return (stringIndexed[index]);
    }

    public void setStringIndexed(int index, String value) {
        stringIndexed[index] = value;
    }
}

. . .

public class BeanUtilsTestCase extends TestCase {
. . .
public void testPopulateIndexedProperty2 {
    // verify populate as String array.
    Map aMap = new HashMap();

    String[] compArray = new String[]
        {"STRIDX 0", "STRIDX 1", "STRIDX 2", "STRIDX 3"};

    aMap.put("stringIndexed", comp);

    BeanUtils.populate(bean, aMap);  // throws IllegalArgumentException!!!
}
}

I believe this should work because TestBean has the array setter method.
    public void setStringIndexed(String value[])

Note, if I remove just the indexed setter it works!
 /* public void setStringIndexed(int index, String value) {
        stringIndexed[index] = value;
    } */

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message