| Author |
Spring: How to set property to value of a property of a bean
|
Robert Willems
Ranch Hand
Joined: Apr 14, 2003
Posts: 32
|
|
Hi all, hopefully somebody knows this. With Spring it is easy to set a property of a bean to another bean. However i need to set the property of a bean to the value of a property of another bean. In non-valid Spring xml i would like something like the following It would set the property named "myProperty" to the valu that was retrieve from the property named "propB" in the bean named "someBean". Does somebody know if this is possible? Thanks in advance... Regards, Robert
|
Regards,<br />Robert Willems of Brilman<br /> <br />----------------------<br /> <br />SCJP 1.4<br />SCWCD 1.3<br />SCWCD 1.4 (beta)<br />SCDJWS 1.4 (beta)<br />SCBCD 1.3 (studying)
|
 |
Robert Willems
Ranch Hand
Joined: Apr 14, 2003
Posts: 32
|
|
Always a joy to finally find an answer to a question. A bit unfortunate if it is about 30 minutes after posting for help ;-). But here is the solution: The PropertyPathFactoryBean can lookup a property of a bean and expose that value as a bean. Cool! Regards, Robert
|
 |
Christophe Verré
Marshal
Joined: Nov 24, 2005
Posts: 14361
|
|
|
Also, you could make your bean BeanFactoryAware and get the value of the other bean using the factory.
|
[SCBCD Wall of Fame] [My Blog]
All roads lead to JavaRanch
Help Japan. Make a donation.
|
 |
 |
|
|
subject: Spring: How to set property to value of a property of a bean
|
|
|