Jump to content

how to refer to bean as the value


sousuke

Recommended Posts

I'm learning about setter Injection using Spring, I was wondering how do I set p:profile (highlighted in bold) to be the bean the profile bean i specified previous, the one with p:name = Chelsea ?setting the other object values was easy because the were just String and ints but i want to set a Profile object.so p:profile = ?

<beans xmlns="http://www.springframework.org/schema/beans"	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"	   xmlns:p="http://www.springframework.org/schema/p"		   xsi:schemaLocation="				http://www.springframework.org/schema/beans				http://www.springframework.org/schema/beans/spring-beans.xsd">	  	  	 <bean id="profile" 		  class="Profile"		  p:name="Chelsea" 		  p:age="20" 		  p:height="151" 		  p:weight="42" 	/>		  					<bean id="mybean" 		  class="Inject"		  p:name="Jason" 		  p:age="24" 		  p:address="Glaxton" 		  p:company="CFX.net" 		  p:email="sentris@cfx.net"		 [b] p:profile =   [/b]	/>			</beans>

Thanks

Link to comment
Share on other sites

I have just figured out how to do it another using property tags and reference tags

<property name = "profile">	 <ref bean="profileBean"/> </property>

but is there a short way to do it similarly to the way i was setting the values in the code shown in my previous post? Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...