S_B
asked on
jakarta Beanutils - exlude methods while copy
I'm using jakarta Beanutils(1.6) for copying values from one to another bean.
As the beanutils use reflections for copying the stuff every getter/setter(origin, destination) pair is called if existing.
An example to make i clearer:
Origin bean:
getStuff()
getDate()
getName()
Destination bean:
setStuff(xx)
setDate(xx)
setName(xx)
Beanutils calls getStuff and sets it on the destination bean via setStuff(xx) while invoking BeanUtils.copyProperties(j ava.lang.O bject dest, java.lang.Object orig)
How do i configure beanutils to exclude some getters to get called, so that in the example above only setDate get's called??
As the beanutils use reflections for copying the stuff every getter/setter(origin, destination) pair is called if existing.
An example to make i clearer:
Origin bean:
getStuff()
getDate()
getName()
Destination bean:
setStuff(xx)
setDate(xx)
setName(xx)
Beanutils calls getStuff and sets it on the destination bean via setStuff(xx) while invoking BeanUtils.copyProperties(j
How do i configure beanutils to exclude some getters to get called, so that in the example above only setDate get's called??
You can just call copyProperty for the properties you want
ASKER
This is what i wanted to avoid as this is a huge bean with lots of properties.
I'm aware of this possibility, but i'm looking for a way to configure the beanutils to skip the designated getter. The way i would solve this would be like this:
Get all methods via beanutils and skip the getters not wanted while copying with copyProperty
But i'm looking for solution to configure this and not coding.
I'm aware of this possibility, but i'm looking for a way to configure the beanutils to skip the designated getter. The way i would solve this would be like this:
Get all methods via beanutils and skip the getters not wanted while copying with copyProperty
But i'm looking for solution to configure this and not coding.
You'd have to override BeanUtilsBean.copyProperti es
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yo. worked for me.
thx for the solution!
lg S.
thx for the solution!
lg S.
No problem
:-)