crudui icon indicating copy to clipboard operation
crudui copied to clipboard

ClassCastException

Open alabotski opened this issue 2 years ago • 3 comments

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

alabotski avatar May 20 '22 11:05 alabotski

How about using "atn" instead of Product.Fields.atn (you don't state what that actually is).

realulim avatar Aug 06 '22 11:08 realulim

@realulim Product.Fields.atn - it's lombok annotation FieldNameConstants https://projectlombok.org/features/experimental/FieldNameConstants

alabotski avatar Aug 07 '22 09:08 alabotski

Ok thanks. So the exception happens when you call setFieldType(...)? Can you show the relevant part of the stacktrace?

realulim avatar Aug 07 '22 10:08 realulim

Closing this. If the issue persist and you can provide additional information, please let us know.

alejandro-du avatar Jul 02 '24 13:07 alejandro-du