Open heruan opened 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.
Here is some more info about wrapping Upload in CustomField https://stackoverflow.com/questions/66154593/vaadin-upload-component-in-binder-e-g-crud-editor
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.