Announcement Announcement Module
No announcement yet.
Re use bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Re use bean

    In our implementation we have initialized bean using map in constructor in ...base.xml
    <bean id="daoFactory" class="factory.DAOFactoryImpl" >
    <constructor-arg index="0">
    <ref bean="AttachmentRequestDAO" />

    Later, we want to add another component to our project and have different xml file say newcomponent.xml and in newcomponent.xml we are importing base.xml.

    The problem is, we want to add another value to the map initialized in base.xml...I tried to use the same bean id and add the another map(key, value) using setter injection but it re-initializes the bean with new value and all old values are lost...

    Is there any way we could the add new property value in different xml to the original bean ?

  • #2
    You can declare your map constructor argument as top level bean and reuse it that way.

    Take a look at Collection merging to see how to add items to a collection



    • #3
      This doesn't solve the problem, because collection merging always merges the child collection, not the parent collection. But in this case, the new values of the child bean should be merged to the parent collection in bean id "daoFactory" in base.xml.

      We have exactly the same problem. Is there any clean solution for this?