Announcement Announcement Module
Collapse
No announcement yet.
Difference between ref bean and idref bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Difference between ref bean and idref bean

    Hi,

    Can anybody please tell me the difference between ref bean and idref bean and ref local and idref local. And when do we use one over the other?

    Thanks,
    John

  • #2
    hello,

    from spring reference:

    The idref element is simply an error-proof way to pass the id of another bean in the container (to a
    <constructor-arg/> or <property/> element).

    using the idref tag allows the container to
    validate at deployment time that the referenced, named bean actually exists.
    So brief: when you use idref spring does an extra validation, but you can only use the id of another bean as reference.

    The difference between bean and local:

    if you use local the other bean should exist in the same page; this is enforced by xml, so if it doesn't your xml is not valid

    Comment


    • #3
      Re: Difference between ref bean and idref bean.

      This isn't a bug, it is working as expected. "ref" is used to pass the bean that the ref refers to. "idref" is used to pass the name of the bean (as a String) that is referred to.
      Reply With Quote

      Comment

      Working...
      X