crudui
crudui copied to clipboard
ClassCastException
Hi my DTO
public class Product extends AuditableEntity {
...
private Integer atn;
...
}
And CrudFormFactory
public class ProductFormFactory extends DefaultCrudFormFactory<Product> {
public ProductFormFactory() {
super(Product.class);
...
setFieldType(Product.Fields.atn, IntegerField.class);
...
}
But I have error
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap') at com.vaadin.flow.component.textfield.AbstractNumberField.setValue(AbstractNumberField.java:40) at com.vaadin.flow.data.binder.Binder$BindingImpl.lambda$convertAndSetFieldValue$4(Binder.java:1441) at com.vaadin.flow.data.binder.Binder$BindingImpl.execute(Binder.java:1532) ... 136 common frames omitted
How about using "atn" instead of Product.Fields.atn (you don't state what that actually is).
@realulim Product.Fields.atn - it's lombok annotation FieldNameConstants https://projectlombok.org/features/experimental/FieldNameConstants
Ok thanks. So the exception happens when you call setFieldType(...)? Can you show the relevant part of the stacktrace?
Closing this. If the issue persist and you can provide additional information, please let us know.