public static class SubmitActionListener extends EventListener<UISampleDownloadUpload> {
public void execute(Event<UISampleDownloadUpload> event) throws Exception {
UISampleDownloadUpload uiForm = event.getSource();
DownloadService dservice = uiForm.getApplicationComponent(DownloadService.class);
List<String> downloadLink = new ArrayList<String>();
List<String> fileName = new ArrayList<String>();
List<String> inputName = new ArrayList<String>();
for (int index = 0; index <= 2; index++) {
UIFormUploadInput input = uiForm.getChildById("name" + index);
UploadResource uploadResource = input.getUploadResource();
if (uploadResource != null) {
DownloadResource dresource = new InputStreamDownloadResource(input.getUploadDataAsStream(),
uploadResource.getMimeType());
dresource.setDownloadName(uploadResource.getFileName());
downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
fileName.add(uploadResource.getFileName());
inputName.add("name" + index);
}
}
for (int index = 3; index < 5; index++) {
UIUploadInput input = uiForm.getChildById("name" + index);
UploadResource[] uploadResources = input.getUploadResources();
for (UploadResource uploadResource : uploadResources) {
DownloadResource dresource = new InputStreamDownloadResource(new FileInputStream(new File(
uploadResource.getStoreLocation())), uploadResource.getMimeType());
dresource.setDownloadName(uploadResource.getFileName());
downloadLink.add(dservice.getDownloadLink(dservice.addDownloadResource(dresource)));
fileName.add(uploadResource.getFileName());
inputName.add("name" + index);
}
}