|
From: Juergen H. <ju...@in...> - 2005-07-20 17:12:21
|
That's actually a good idea... I wouldn't call it a fix, rather an enhancement: Old values simply weren't exposed to PropertyEditors before. I've just reworked BeanWrapperImpl accordingly. After some fine tuning, everything seems to run nicely. I'm gonna release this in 1.2.3. If there's any further refinements in that area that you'd like to see, let me know :-) Juergen -----Original Message----- From: spr...@li... [mailto:spr...@li...] On Behalf Of Tom Turelinckx Sent: Wednesday, July 20, 2005 10:32 AM To: spr...@li... Subject: [Springframework-developer] property editor doesn't know existing property value when setting new value using BeanWrapperImpl When using BeanWrapperImpl to set the value of a property where a property editor is involved, doTypeConversionIfNecessary() calls setAsText() and then getValue() on the property editor, but it does not first call setValue() with the existing property value. Hence, you cannot use getValue() in the setAsText() method to get the existing property value... I accidentally discovered this when trying to get MutableSortDefinition's toggleAscendingOnProperty functionality to work when binding a sortDefinition request parameter on a bean that is kept in the session. It doesn't work, because my property editor's setAsText() method never updates the existing MutableSortDefinition property value - getValue() is always null and a new instance is created every time. Actually, I would really expect this to work... I have a lot of custom property editors where setAsText() performs a database lookup by primary key, but first performs a !getAsText().equals(text) check to verify the lookup is actually necessary. Probably, this doesn't work either, because getAsText() calls getValue() to transform the existing property value into a String representation... In fact, when looking at BeanWrapperImpl's source, it turns out the oldValue parameter passed to doTypeConversionIfNecessary is explicitly specified as null everywhere the method is called, but the parameter is only used for creating property change events anyway. I searched the forums and noticed there's already a "discussion" going on ;-) http://forum.springframework.org/viewtopic.php?t=3440 I couldn't find a JIRA issue for this yet, so I've created one: http://opensource.atlassian.com/projects/spring/browse/SPR-1155 Any chance this can be fixed? Thanks, Tom. ------------------------------------------------------- SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click _______________________________________________ Springframework-developer mailing list Spr...@li... https://lists.sourceforge.net/lists/listinfo/springframework-developer |