"This is a HUGE problem with BeanUtils and why I end up having to register custom converters:("
good point, but where do I register my custom converters? I dont want to do it in my action classes, and writing a plugin just to register my converters would be a big overhead. Why cant we have declative registration through struts-config.xml, just like other components and struts should take care of registering my converters with ConvertUtil? (If its not already done yet!) This would actually give me flexibility to have my custom types as well in the form bean. Lets say, for some application I want all java.util.Long types to be appended with "$" symbol, it becomes much easier with a converter. what do you say? Thanks and Regards, Nitish Kumar -----Original Message----- From: Rick Reumann [mailto:[EMAIL PROTECTED] Sent: Monday, July 11, 2005 11:17 PM To: Struts Users Mailing List Subject: Re: Using struts forms as Value Objects: your opinion? Borislav Sabev wrote the following on 7/11/2005 1:37 PM: > In case of the Integer there is pre-load default value and EVEN if > conversion fails during the population phase, it just use is the dafault > value (and you think it's parsed correctly). In the previous example its > a coincidence that Rivka have 0 as default value (it's just the same > value as init value of IntegerConverter). Bingo:) Sorry saw this thread late and could have helped out much sooner. This is a HUGE problem with BeanUtils and why I end up having to register custom converters:( BeanUtils (at least it always has done this, maybe in a recent version it's hopefully changed?), will end up converting null values to 0!! Stupid, stupid if you ask me (null means null not 0!) Goes the same for the other numeric wrappers as well. (I think their argument was for backwards compatibility with apps that expect that behavior). In regard to you point... > The strange point is that I didn't find how can I set a default date > value ... if someone knows it, please share this knowledge here. You shouldn't want a "default" at all provided by BeanUtils for cases where it can be null! You are using the anomoly of the way Integer is working and wanting to propogate that poor solution. null should be null.. it shouldn't be 0 or some default Date if null is provided. If you want a default Date or some other default than provide that before going to your form...or if after it submits and you see a null, then provide the default. You could of course register your own converter to provide a default for when a Date is null- but I would NOT do this. Actually, in regards to a Date, in case you didn't already realize, you'll have to provide your own converter anyway if you plan to use java.util.Date since BeanUtils doesn't provide that by default.. it only provides conversion for java.sql.Date. If you need help with the converters I can post some code or search the struts archives for "java.util.Date converter" -- Rick --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]