aspose file tools*
The moose likes Struts and the fly likes BeanUtils issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "BeanUtils issue" Watch "BeanUtils issue" New topic
Author

BeanUtils issue

Nicolas Flammel
Ranch Hand

Joined: May 05, 2004
Posts: 32
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 ]
Jason Menard
Sheriff

Joined: Nov 09, 2000
Posts: 6450
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

Joined: May 05, 2004
Posts: 32
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

Joined: Nov 09, 2000
Posts: 6450
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BeanUtils issue
 
Similar Threads
General Queries regarding JSPs.
opening a created PDF in internet browser
begin execution of a thread -- start or run?
List to Map conversion
juice