aspose file tools*
The moose likes Spring and the fly likes How to set bean value to empty or null if the property is not provided? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "How to set bean value to empty or null if the property is not provided?" Watch "How to set bean value to empty or null if the property is not provided?" New topic
Author

How to set bean value to empty or null if the property is not provided?

Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hello,
Thanks for reviewing my post. I've created a bean using a value from the system properties. If the system property value is not provided, I would like to handle that in the Java code. Is it possible to do this?

Using
Spring 2.5
Java 5.0
JBoss 5.1

Thank you in advance for your help.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

You can always set properties to default values directly in your code.



Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Shannon Sims
Ranch Hand

Joined: Jul 03, 2003
Posts: 197
Hi Mark,
Sorry about the delay in responding. Thanks for responding to my post and your solution. Yes, your solution would definitely work if I didn't have a typo in my post...I was actually looking to see if I omit the key/value from the system properties, if I could have the bean check for a null key/value pair before setting the bean property value. I couldn't get the app to run without the key, so to work around this, I'm setting the key to an empty string. If you have another solution, I would appreciate it.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to set bean value to empty or null if the property is not provided?
 
Similar Threads
Spring Framework + JPA and many database schemas
Spring: Not able to redirect to a bean
JSP with No Java!
using spring expressions
Dynamic bean.xml in Spring Framework