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]