Results 1 to 3 of 3

Thread: Using bean id in bean itsself

  1. #1
    Join Date
    Aug 2011
    Posts
    2

    Default Using bean id in bean itsself

    Hi!

    I already searched on google and in forums, but i couldn't find any informations about it.
    I need to set the bean id on a field on the bean itsself.
    My (dummy) code:

    Code:
    public class MyConfigEntry
    {
        private String name;
        private String startCommand;
        /*getter, setter*/
    }
    
    <beans>
    	<bean id="firstCommand" class="MyConfigEntry">
                <property name="name" value="firstCommand" />
                <property name="startCommand" value="anyCommand" />
    	</bean>
    	<bean id="secondCommand" class="MyConfigEntry">
                <property name="name" value="secondCommand" />
                <property name="startCommand" value="anyCommand" />
    	</bean>
    </beans>
    as you see i always have to write bean id and name property of MyConfigEntry twice. Is there any possibility to get the bean id into property "name"?

    i use spring 2.5.6 with jdk 1.6.0_23

    yours sincerly Phylanx

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,632

    Default

    Well search again ... You want BeanNameAware.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2011
    Posts
    2

    Default

    hi!

    thank you for your fast reply.
    it's hard to find things if you don't know the right key words.

    sry for disturbing
    1 million times thank you!
    Phylanx

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •