This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other Application Frameworks and the fly likes Dynamic bean.xml in Spring Framework Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Dynamic bean.xml in Spring Framework" Watch "Dynamic bean.xml in Spring Framework" New topic
Author

Dynamic bean.xml in Spring Framework

tusharlondhe londheAdmin
Greenhorn

Joined: Apr 08, 2009
Posts: 1
Hi Guys,

I have a bean.xml

<bean id="User" class="com.module.spring.basic.User">
<property name="userName">
<value>ABCD</value>
</property>
</bean>

Now how to make this bean.xml dynamic so that I can pass user provided values.
Bhagat Singh Rawat
Ranch Hand

Joined: Apr 04, 2009
Posts: 93
tusharlondhe londheAdmin wrote:Hi Guys,

I have a bean.xml

<bean id="User" class="com.module.spring.basic.User">
<property name="userName">
<value>ABCD</value>
</property>
</bean>

Now how to make this bean.xml dynamic so that I can pass user provided values.



Once you get the bean instance by using ctx.getBean("User"), then you can set dynamic name value as userBean.setUserName("User_New_Name") before using the hard coded name "ABCD".


Brainbench Java 2.0 Fundamentals, J2EE 1.4
http://www.brainbench.com/transcript.jsp?pid=8192792
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

And I would only set the property in the xml, only if I wanted a default value, and even then if it isn't deploy specific, then I would put the default value in my code.

Anyway, just because you set a property in configuration doesn't mean that you can never call the setter method yourself in code once you get a reference to it.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
 
subject: Dynamic bean.xml in Spring Framework
 
Similar Threads
java.lang.InstantiationException
[beans.xml] cannot be opened because it does not exist
Why this error?
value and binding attribute
how can i configure spring with hibernate shard?