|
From: Les A. H. <le...@ha...> - 2004-01-30 23:40:25
|
Gents,
Using the Spring web mvc stuff, I understand we need PropertyEditors for certain
fields. I've been ok using them up until now, but now I seem to be stuck.
I have a form which lists ip addresses, one field per ip, all named
"ipAddresses" (thereby making the request parameter a String[] with the values
from all fields). I have a JavaBean that requires a java.util.Set of
InetAddresses.
in the initBinder() method I specify my custom InetAddressSetEditor which takes
in a comma-delimited string of ip addresses in the setAsText method.
All I do is tokenize that string, call InetAddres.getHostName() for each
returned token and finally call setValue(myNewlyConstructedSet) and return.
I turned on the DEBUG info level in Spring and see that it never acquired my
PropertyEditor in the BeanWrapperImpl class, specifically in the
public Object doTypeConversionIfNecessary
method starting on line 678. The failure occurs on one of the checks to see if
my property editor is null (starting on line 712).
Here's my debug output:
DEBUG [BeanWrapperImpl] Convert: StringArray to CommaDelimitedString
[10.0.0.1,127.0.0.1]
DEBUG [BeanWrapperImpl] Convert: String to [interface java.util.Set]
DEBUG [BeanWrapperImpl] Using property editor [null]
How come my property editor isn't being set?
My method from my subclass of SimpleFormController:
protected void initBinder( HttpServletRequest request,
ServletRequestDataBinder binder ) {
binder.registerCustomEditor(java.util.Set.class,
new InetAddressSetEditor());
}
What gives? What did I do wrong?
Thanks very much for any early replies...I'm hitting a deadline later today and
this is all that holds me up....
Regards,
Les
P.S. I understand this is a general user question, but because of the code
references, I figured it would be better suited to the developers list.
|