I'm having a problem with SimpleFormController trying to bind data types incorrectly. The id of my command object will not bind because it cannot find a PropertyEditor. The implementation of my command class uses Integer as the required type but the Interface is generic and requires anything that extends Number (so we can use either Integer or Longs as the ID). Spring is trying to find a PropertyEditor of type Number (which obviously can't exist because Number is Abstract).
I'm not sure why it would use the interface's method signature for the type when we told it about the implementation. It should even really know or care about it's interface. If someone could please shed some light on the situation, I'd be forever greatful. I'm not sure how to fix this situation. Forcing a custom mapping for Number to Integer breaks other data types that my form uses (doubles for instance).
I've confirmed that it sees the required type as Number in BeanWrapperImpl (line 979). findCustomEditor returns null.
command config for my SimpleFormController:
Inventory is a implementation of GenericEntity. Generic entity is defined as such:Code:<property name = "commandClass"> <value>com.mycompany.myapp.domain.model.Inventory</value> </property>
Inventory's implementation of getId uses an Integer for it's implementation (code snipped for brevity):Code:package com.mycompany.common.domain.model; import java.io.Serializable; public interface GenericEntity<ID extends Number> extends Serializable { public ID getId(); public Integer getVersion(); public void setId(ID id); public void setVersion(Integer version); }
Binding error:Code:public class Inventory implements GenericEntity<Integer> { private Integer id; public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; }
Code:Failed to convert property value of type [java.lang.String] to required type [java.lang.Number] for property id


Reply With Quote