• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BeanUtils issue

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BeanUtils.copyProperties(bean, formBean) works fine. But I have a form bean with a String array and I want to copy this too into the java bean; but I get an exception when doing this as:
java.lang.IllegalArgumentException: argument type mismatch
Is copyProperties() not valid for arrays?? Then what is the other way out to copy form bean values into the java bean??

[ May 21, 2004: Message edited by: Nicolas Flammel ]
[ May 21, 2004: Message edited by: Nicolas Flammel ]
 
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BeanUtils.copyProperties() does work with String arrays (I just double checked by running some test code). It's possible that there is some error in your code. The first thing to check is that you are positive it is trying to copy a String[] attribute in one form or bean to an attribute in another form or bean that is also a String[]. Are you positive that the exception is occuring because of the String[]? Maybe you could post some of the code here and we can take a look at it, such as the definitions of the two objects involved, and the code being used to copy them.
 
Nicolas Flammel
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The array in my form bean is of type String which is being populated from the form parameters during submission(Struts)(obviously) and the one in the bean is of type Integer(as I need the same in this type). But BeanUtils.copyProperties() does auto conversion to the required types right???
 
Jason Menard
Sheriff
Posts: 6450
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm pretty sure copyProperties() does attempt to do type conversion. I probably need to study the BeanUtils source to figure out why this doesn't work. I know that the ConvertUtils class should convert a String[] to an Integer[]. I also know that using using setProperty() will correctly perform the conversion from String[] to Integer[], although copyPropery() (which is called internally by copyProperties()) does not seem to handle this conversion correctly from String[] to Integer[], although it will handle it from String to Integer. Interesting.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic