Saturday, 2 September 2017

ref vs. idref


ref attribute vs. idref tag

ref attribute can point to a Bean ID, Name or Alias, but idref tag only point to Bean ID.
IDRef makes sure there should be a bean defined with the specified bean ID, otherwise throw an exception.

<bean id="triangle" class="com.shaan.exmaple.Triangle">
    <property name="point1" ref="pointOne" />
</bean> 
Looks for "pointOne" as a bean ID, bean name or alias.


<bean id="triangle" class="com.shaan.exmaple.Triangle">
   <property name="point1">
      <idref="pointOne" />
   </property>
</bean>
Looks for "pointOne" in the bean IDs only.

No comments:

Post a Comment

Note: only a member of this blog may post a comment.