PDA

View Full Version : setting property of one bean using property of other bean


harishachar
Aug 8th, 2005, 09:18 AM
Hi,

I am new to Spring Framework, and I need help implementing the following scenario using Spring core Framework.
I have 2 classes Class A and Class B. Class A has an ArrayList of Class B and Class B contains the properties of class A.

I would really appreciate if someone could help me on this. Also please point me to the resources where I can find the solution for the same.

Thanks & Regards
Harish

paskos
Aug 8th, 2005, 01:01 PM
Hi,

I guess you will have a lot more chances of getting answers if you post the same question in the following forum :
http://forum.springframework.org/viewforum.php?f=4

klr8
Aug 8th, 2005, 02:41 PM
Take a look at chapter 3 of the spring reference documention for details on how to define something like that in a Spring application context (http://static.springframework.org/spring/docs/1.2.x/reference/beans.html).

You would end up with something like this:
<bean id="a" class="A">
<property name="bList">
<list>
<ref bean="b0"/>
<ref bean="b1"/>
</list>
</property>
</bean>

<bean id="b0" class="B">
<property name="prop" value="foo"/>
</bean>
<bean id="b1" class="B">
<property name="prop" value="bar"/>
</bean>


Erwin

harishachar
Aug 9th, 2005, 11:35 PM
Hi,

Thanks a lot everyone for your help.

Regards
Harish