alejandro-du / crudui

Automatically generate CRUD-like Vaadin views for any Java Bean
https://vaadin.com/directory#!addon/crud-ui-add-on
Apache License 2.0
85 stars 54 forks source link

ClassCastException #105

Closed alabotski closed 2 weeks ago

alabotski commented 2 years ago

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

realulim commented 1 year ago

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

alabotski commented 1 year ago

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

realulim commented 1 year ago

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

alejandro-du commented 2 weeks ago

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