vaadin / flow-components

Java counterpart of Vaadin Web Components
101 stars 66 forks source link

API to pre-fill the list of files and Binder support #1571

Open heruan opened 5 years ago

heruan commented 5 years ago

The Web Component has a mean to pre-fill the list of files: upload-advanced-demos#pre-filling-the-file-list-in-advance

It would be useful to have a Java API for this.

heruan commented 5 years ago

What about making Upload a proper field? So its list of files can be bound to a bean. I imagine a FileData interface, so the user can use a converter to bind its own type, e.g.

class Article {
   List<Attachment> attachments;
   // getter and setter
}

var upload = new Upload();
binder.forField(upload)
       .withConverter(/* custom FileData <-> Attachment converter */)
       .bind(Article::getAttachments, Article::setAttachments);

This way for an existing bean the list of files will be pre-filled.

TatuLund commented 2 years ago

Here is some more info about wrapping Upload in CustomField https://stackoverflow.com/questions/66154593/vaadin-upload-component-in-binder-e-g-crud-editor