I have a problem with form objects that have java.lang.Boolean data types that use the "is" construct for getter method names. I am getting the following error:
Upon digging closer, it seems as though the java.beans.PropertyDescriptor really doesn't handle the Boolean wrapper class all that well as it does this for the "getReadMethod()":Code:2007-04-24 12:43:38,737 [http-9090-Processor25] ERROR org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/webta].[webta] - Servlet.service() for servlet webta threw exception org.springframework.beans.NotReadablePropertyException: Invalid property 'user.accessibilityRequired' of bean class [UserMaintenanceForm]: Bean property 'user.accessibilityRequired' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter? at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:534) at org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:526) at org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:77) at org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:337) at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:117) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:179) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.resolveCssClass(AbstractHtmlElementTag.java:502) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:479) at org.springframework.web.servlet.tags.form.AbstractHtmlInputElementTag.writeDefaultAttributes(AbstractHtmlInputElementTag.java:176) at org.springframework.web.servlet.tags.form.CheckboxTag.writeTagContent(CheckboxTag.java:79) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:93) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:77)
As you can see, if you are not using the primitive boolean, the use of "is" is not permitted and it assumes the "get" form of the getter method. Is this a bug in JDK 1.5? With autoboxing/unboxing you would think boolean.class and Boolean.class would be interchangeable. I am currently using the "is" construct for the getter for all my java.lang.Booleans and we are at the point that this cannot be changed. Does anyone have any suggestions to get around this?Code:... Class type = getPropertyType0(); if (type == boolean.class || type == null) { readMethodName = "is" + getBaseName(); } else { readMethodName = "get" + getBaseName(); } } ...


Reply With Quote