Re: improve documentation for UploadedFilesAware

Lukasz Lenart <[email protected]>
Newsgroups gmane.comp.jakarta.struts.devel
Message-ID <CAMopvkO5i+OAZcAQh=RR9YD5_VZa8Exb_HuV7MLxdfLbFBZmBA@mail.gmail.com>
pon., 26 lut 2024 o 12:08 Greg Huber <[email protected]> napisał(a):
>
> The documentation only lists one file
>
> |public void withUploadedFiles(List<UploadedFile> uploadedFiles) { if
> (!uploadedFiles.isEmpty()) { this.uploadedFile = uploadedFiles.get(0);
> this.fileName = uploadedFile.getName(); this.contentType =
> uploadedFile.getContentType(); this.originalName =
> uploadedFile.getOriginalName(); } }|
>
> For multiple files these need populating
>
> privateFile[]uploadedFiles=null;
>
> privateString[]uploadedFilesContentType=null;
>
> privateString[]uploadedFilesFileName=null;
>
> We have to loop and do it ourselves now?

Basically it would be better to stop using additional fields if not
needed. You can achieve the same behaviour just exposing getters
extracting what's needed from "uploadedFiles", eg:

public void withUploadedFiles(List<UploadedFile> uploadedFiles) {
  this.uploadedFiles = uploadedFiles;
}

public String[] getUploadedFilesContentType() {
  return this.uploadedFiles.stream().map(UploadedFile::getContentType).toArray();
}

etc.


Cheers
Lukasz
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.