Christian
Mar 1st, 2006, 12:38 PM
Hi,
I have a simple question: Can you access bean properties inside a bean
definition file in the way you would do it in a JSP page?
Example:
public class Person{
private String name;
public String getName(){return name;}
public void setName(String name){this.name= name;}
}
public class Dog{
private String dogName;
public String getDogName(){return dogName;}
public void setDogName(String dogName){this.dogName = dogName;}
}
<beans>
<bean id="p" class="Person">
<property name="name" value="Jonny"/>
</bean>
<bean id="d" class="Dog">
<property name="dogName" ref="p.name"/>
</bean>
</beans>
The important part is the p.name in the Dog bean definition. I tried it using
several variations but with no avail. You can use a factory method to achive this. But this results in a rather verbose bean definition.
I guess I have just made a silly mistake somewhere, so please let me know.
regards
Chris
I have a simple question: Can you access bean properties inside a bean
definition file in the way you would do it in a JSP page?
Example:
public class Person{
private String name;
public String getName(){return name;}
public void setName(String name){this.name= name;}
}
public class Dog{
private String dogName;
public String getDogName(){return dogName;}
public void setDogName(String dogName){this.dogName = dogName;}
}
<beans>
<bean id="p" class="Person">
<property name="name" value="Jonny"/>
</bean>
<bean id="d" class="Dog">
<property name="dogName" ref="p.name"/>
</bean>
</beans>
The important part is the p.name in the Dog bean definition. I tried it using
several variations but with no avail. You can use a factory method to achive this. But this results in a rather verbose bean definition.
I guess I have just made a silly mistake somewhere, so please let me know.
regards
Chris