Hi,
I'm having problems validating a field that is a boolean. In my
javabean I have a property "female" which is of type boolean (primitive
boolean) and has a corresponding setter "setDoNotEmail(boolean
doNotEmail)". I'm doing this because I'm trying to validate a
JCheckBox.
In my xml config file I've tried both:
<element name="doNotEmail" optional="true">
<write-method>setDoNotEmail</write-method>
</element>
Because from what I can tell the converter doesn't apply as the original
value is actially of type boolean and doesn't require conversion.
When I try to run validation I get in my log:
2004-08-23 22:52:31,35338736 [AWT-EventQueue-0] DEBUG org.formproc.Form
: Validating field doNotEmail
2004-08-23 22:52:31,35338736 [AWT-EventQueue-0] DEBUG org.formproc.Form
: Using validator:org.formproc.validation.PassValidator@18d7ace
2004-08-23 22:52:31,35338736 [AWT-EventQueue-0] DEBUG org.formproc.Form
: Validation complete.
2004-08-23 22:52:31,35338736 [AWT-EventQueue-0] DEBUG
org.formproc.store.ReflectionStorer : Storing value:true
2004-08-23 22:52:31,35338736 [AWT-EventQueue-0] INFO org.formproc.Form
: No method found for parameter doNotEmail
Looking at the store(...) method of ReflectionStorer it looks like it
did intelligently convert the boolean to a Boolean as the value
parameter must be an Object, however the MethodUtilities.invoke(...)
must not be able to reflectively find the setter method. And since the
MethodUtilities class is hidden away in the edenlib.jar file I can't see
what's going on.
When I add the setter method setDoNotEmail(Boolean doNotEmail) using the
Boolean object it seems to work. This is strange to me because when
I've coded reflection in the past I know you have to specify the Boolean
wrapper class for the method signature but it will find a method that
uses the primitive.
Is there a way for me to not implement a setter for a boolean property
only using the primitive setter method?
Thanks,
Christian
_____________________________________
Help the Lance Armstrong Foundation
support people living with cancer.
http://www.wearyellow.com <http://www.wearyellow.com/>
|