Announcement Announcement Module
Collapse
No announcement yet.
Child bean definition has neither 'id' nor 'name' error Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Child bean definition has neither 'id' nor 'name' error

    I want to use Spring to populate a list which will be used in a JSP. I don't want to store references to the individual beans (with id, etc), and fortunately I don't have to, the following works just fine, with merely the class being specified, and then the properties for each bean being assigned.

    <property name="optionList">
    <list>
    <bean class="testing.web.ListViewSelectOption">
    <property name="name">
    <value>id</value>
    </property>
    <property name="textLength">
    <value>5</value>
    </property>
    etc...

    Where it comes unstuck is that I want to be able to specify a parent bean, containing some default properties so all the properties don't have to be specified each time. Thus I modify the above so I have:

    <bean id="basicOption" class="sailingnetworks.web.ListViewSelectOption"/>
    [default properties set]

    and for each bean:

    <bean parent="baseOption">

    Now, though, when it is inheriting from a parent, I get the following error:
    org.springframework.beans.factory.BeanDefinitionSt oreException: Error registering bean with name '' defined in file [/opt/projects/testing/listViewApplicationContext.xml]: Child bean definition has neither 'id' nor 'name'

    So it only objects to not having an id or name when it is inheriting from a parent bean, which seems odd. I don't know whether this is a bug, or something I'm doing. It's with Spring 1.1.1.

  • #2
    You should try 1.1.3. If this was indeed happening in 1.1.1, it doesn't happen in 1.1.3. There's no problem having an inner bean in 1.1.3 which derives from a parent, and doesn't specify any name or id.

    Comment


    • #3
      Originally posted by Colin Sampaleanu
      You should try 1.1.3. If this was indeed happening in 1.1.1, it doesn't happen in 1.1.3. There's no problem having an inner bean in 1.1.3 which derives from a parent, and doesn't specify any name or id.
      You're absolutely right, 1.1.3 fixes this. Wonderful, thanks!

      Comment

      Working...
      X