Ad

Vaadin Excel Uploader Issue

- 1 answer

I am developing a web application using Spring Boot and Vaadin Framework which suppose to have a feature of processing Microsoft Excel documents, storing data from spreadsheets in custom Java objects, and finally persisting them to database. I am using the Excel Uploader add-on from Vaadin's directory which handles this kind of stuff.

As it is shown in the official examples to this add-on, it perfectly works for populating Vaadin Grid component with data from a spreadsheet and reads it properly with no issues. However, I have problems when I try to store this data in a custom object and call any method of this data type, due to the ClassCastException. This exception is thrown because the program tries to cast objects of the same data types. The thing is that whenever I want to add a SucceededListener using a lambda, the data gathered from an excel document is referenced as a collection of the generic Object type, hence it is needed to cast it to a custom object in order to call specific methods. However, when the program runs and I try to upload an excel document via UI this exception is thrown because that collection of generic Objects becomes a collection of custom data types at some moment.

This is the method where the Excel Uploader is configured:

public void configureExcelUploader() {
    ExcelUploader<Person> excelUploader = new ExcelUploader<>(Person.class);
    excelUploader.addSuccededListener((event, items)) -> {
        List<Person> persons = (List<Person>) items;
        persons.callCustomMethod();
    });

    Upload uploadButton = new Upload("Upload");
    uploadButton.setReceiver(excelUploader);
    uploadButton.addSucceededListener(excelUploader);
}

I probably miss something or simply do not how to do this kind of operation properly. Is there anyone who knows a proper way of storing results in a custom object in this particular case?

Ad

Answer

I solved this problem by removing DevTools from maven dependencies and everything worked perfectly.

Ad
source: stackoverflow.com
Ad