|
From: Tom T. <tom...@pr...> - 2005-07-20 08:32:07
|
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. |